Exemplo n.º 1
0
func (r *registerForm) IsValid() bool {
	user, _ := common.FindUserByEmail(r.Email)
	if user != nil {
		r.Valid.SetError("Email", "This email is already taken")
		return false
	}
	return true
}
Exemplo n.º 2
0
// Check of user exists by email and password
func userExists(form *loginForm) error {
	user, _ := common.FindUserByEmail(form.Email)

	if user == nil {
		return errors.New("User not found")

	}

	err := common.CompareHashAndPassword(user.Password, form.Password)
	if err != nil {
		return err
	}

	return nil
}