Ejemplo n.º 1
0
func (h HomeController) Before_Controller_Filter(context *gofcore.HttpContext) {
	v := context.GetSession("username")
	if v == nil && context.ActionName != "login" {
		h.RedirectToAction(context, "login")
		return
	}
}
Ejemplo n.º 2
0
func (h HomeController) PostLogin(context *gofcore.HttpContext, user models.User) (viewResult *gofcore.ViewResult) {
	if user.Name == "justinhuang" && user.Password == "123" {
		context.SetSession("username", "justinhuang")
		h.RedirectToAction(context, "index")
	} else {
		viewResult = h.View(*&models.User{"", "", -1, 0}, context)
	}
	return
}