コード例 #1
0
func (c *UserController) Session() {
	name := c.GetString("name")
	password := c.GetString("password")

	needCheckCaptcha := c.NeedCheckCaptcha()
	if needCheckCaptcha {
		result := c.VerifyCaptcha()
		if !result {
			c.RecordLoginFailTimes()
			c.StringError(exception.CAPTCHA_FALSE.Error())
			c.Data["showLeftBar"] = false
			c.TplName = "login.html"
			return
		}
	}

	user, err := services.FundUser(name, password)
	if err == nil {
		c.SetCurrSession("user", user)
		c.Ctx.Redirect(302, "/")
	} else {
		c.RecordLoginFailTimes()
		c.StringError(exception.USER_NAME_OR_PASS_UNMATCH.Error())
		c.Data["showLeftBar"] = false
		c.TplName = "login.html"
	}
}
コード例 #2
0
func (c *UserController) OauthSession() {
	name := c.GetString("name")
	password := c.GetString("password")

	needCheckCaptcha := c.NeedCheckCaptcha()
	if needCheckCaptcha {
		result := c.VerifyCaptcha()
		if !result {
			c.RecordLoginFailTimes()
			c.StringError(exception.CAPTCHA_FALSE.Error())
			c.OauthLogin()
			return
		}
	}

	user, err := services.FundUser(name, password)
	if err == nil {
		c.SetCurrSession("user", user)
		c.Ctx.Redirect(302, "/")

		openUser := c.CurrentOpenUser()
		beego.Debug("openuser:"******"openUser", openUser)
		}
		return
	}

	c.StringError(exception.USER_NAME_OR_PASS_UNMATCH.Error())

	c.RecordLoginFailTimes()

	c.OauthLogin()

}