예제 #1
0
func (t *LoginController) Post() {
	name := t.Input().Get("uname")
	pwd := t.Input().Get("pwd")
	autoLogin := t.Input().Get("autoLogin")
	fmt.Println("name", name, "pwd", pwd, "auto", autoLogin)
	isright := models.CheckPassword(name, pwd)
	fmt.Println("5555555555", "name", name, "pwd", pwd, isright)

	maxAge := 0
	maxAge = 1<<31 - 1

	t.Ctx.SetCookie("name", name, maxAge, "/")
	t.Ctx.SetCookie("pwd", pwd, maxAge, "/")
	if isright {
		t.TplNames = "Home.html"
		/*t.Data["Author"] = "叶青,子龙"
		t.Data["Time"] = time.Now().Format(time.Stamp)
		t.Data["IsHome"] = true
		t.Data["IsLogin"] = true*/
		t.Redirect("/", 302)
		return
	}
	namestruct, err := t.Ctx.Request.Cookie("name")
	if err == nil {
		aname := namestruct.Value
		t.Data["UserName"] = aname
	}

	t.TplNames = "Login.html"
	return
}
예제 #2
0
func CheckAccount(t *context.Context) bool {
	n, err := t.Request.Cookie("name")
	if err != nil {
		return false
	}
	name := n.Value

	p, err := t.Request.Cookie("pwd")
	if err != nil {
		return false
	}
	password := p.Value
	isright := models.CheckPassword(name, password)
	return isright
}