Exemplo n.º 1
0
// Generates a new password for the user with a new salt.
func newPassword(password string) Password {
	salt := utils.RandomString(64)

	return Password{
		hash: generatePassword(password, salt),
		salt: salt,
	}
}
Exemplo n.º 2
0
// Give the user a new (temporary) password and send it to them through an
// email.
func (s UserService) Recover(email string) *utils.GoAuthError {
	user, err := s.repository.findByEmail(email)
	if err != nil {
		return err
	}

	user.setPassword(utils.RandomString(8))
	err = s.repository.saveUser(user)
	if err != nil {
		return err
	}

	// @TODO: send mail to the user.

	return err
}
Exemplo n.º 3
0
// A helper function to generate the verification tokens.
func generateNewToken() string {
	return utils.RandomString(16)
}
Exemplo n.º 4
0
// A helper function which actually does the generating of an ID.
func generateNewID() string {
	return utils.RandomString(15)
}