Exemplo n.º 1
0
//POST /account/login
func (c *Account) PostLogin(user models.User) revel.Result {
	//check input legality
	c.Validation.Email(user.Email)
	c.Validation.Required(user.Password)
	if c.Validation.HasErrors() {
		c.Validation.Keep()
		//c.FlashParams()
		return c.Redirect(routes.Account.Login())
	}

	if !user.LoginOk() {
		c.Validation.Keep()
		c.FlashParams()
		c.Flash.Error("account or password is incorrect")
		return c.Redirect(routes.Account.Login())
	} else {
		c.Session[USERNAME] = user.Name
	}
	return c.Redirect("/code/status")
}