Exemplo n.º 1
0
Arquivo: users.go Projeto: coddo/gost
// ActivateAppUser activates an application user based on its token
func ActivateAppUser(token string) error {
	var user, err = identity.GetUserByActivationToken(token)
	if err != nil {
		return err
	}

	if util.IsDateExpiredFromNow(user.ActivateAccountTokenExpireDate) {
		return ErrActivationTokenExpired
	}

	user.AccountStatus = identity.AccountStatusActivated

	return identity.UpdateUser(user)
}
Exemplo n.º 2
0
Arquivo: users.go Projeto: coddo/gost
// ResetPassword resets the password of an application user
func ResetPassword(token, password string) error {
	var user, err = identity.GetUserByResetPasswordToken(token)
	if err != nil {
		return err
	}

	if util.IsDateExpiredFromNow(user.ResetPasswordTokenExpireDate) {
		return ErrResetPasswordTokenExpired
	}

	passwordHash, err := util.HashString(password)
	if err != nil {
		return err
	}

	user.Password = passwordHash

	return identity.UpdateUser(user)
}
Exemplo n.º 3
0
// IsExpired returns true if the session has expired
func (session *Session) IsExpired() bool {
	return util.IsDateExpiredFromNow(session.ExpireTime)
}