Exemple #1
0
func (this *loginC) Login_post(ctx *web.Context) {
	r, w := ctx.Request, ctx.ResponseWriter
	r.ParseForm()
	usr, pwd := r.Form.Get("uid"), r.Form.Get("pwd")
	pt, result, message := this.ValidLogin(usr, pwd)

	if result {
		ctx.Session().Set("partner_id", pt.Id)
		if err := ctx.Session().Save(); err != nil {
			result = false
			message = err.Error()
		}
	}
	web.Seria2json(w, result, message, nil)
}
Exemple #2
0
func (this *loginSession) AdministratorLogin(w http.ResponseWriter, usr string, pwd string) bool {
	loginTokenResult := domain.Md5PartnerPwd(usr, pwd)
	loginResult := loginTokenResult == ctx.App.Config().GetString("master_token")

	if loginResult {

		//存入cookie
		expires := time.Now()
		expires = expires.Add(3600 * 72 * 1e9) //72H
		cookie := http.Cookie{Name: "mtkey",
			Value:   loginTokenResult,
			Expires: expires}
		http.SetCookie(w, &cookie)
		web.Seria2json(w, true, "", nil)
		return true
	}
	return false
}