Example #1
0
func (c Auth) HandleRegister(user *models.User) revel.Result {
	user.ValidateCreate(c.Validation)

	if c.Validation.HasErrors() {
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect("register")
	}

	return c.Redirect("register")
}
Example #2
0
func (c Auth) HandleLogin(user *models.User) revel.Result {
	user.ValidateLogin(c.Validation)

	if c.Validation.HasErrors() {
		c.Validation.Keep()
		c.FlashParams()
		c.Flash.Error("Incorrect username or password.")
		return c.Redirect("login")
	}

	authenticated := c.GordenManager().Authenticate(AuthenticateParams{user.Email, user.Password})
	if authenticated {
		c.Flash.Success("Login Worked")
		return c.Redirect("login")
	}

	c.Flash.Error("Incorrect username or password.")
	return c.Redirect("login")
}