コード例 #1
0
func (c App) connected() *models.User {
	//	if c.RenderArgs["user"] != nil {
	//		return c.RenderArgs["user"].(*models.User)
	//	}
	if username, ok := c.Session["user"]; ok {
		return models.GetUser(username)
	}
	return nil
}
コード例 #2
0
func (c App) Login(username, password string) revel.Result {
	if username != "" {
		user := models.GetUser(username)
		if user != nil {
			if user.VerifyPassword(password) {
				c.Session["user"] = username
				c.Flash.Success("Welcome, " + username)
				return c.Redirect("/")
			}
		}
		c.Flash.Out["username"] = username
		c.Flash.Error("Login Failed")
		return c.Redirect("/")
	}
	return c.Render()
}