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() }
func (c *UserController) oauthCreateUser() { var user entities.User user.Name = c.GetString("name") user.Mail = c.GetString("mail") user.Password = c.GetString("password") user.Nick = user.Name openUser := c.CurrentOpenUser() beego.Debug("openuser:"******"user", user) c.Ctx.Redirect(302, "/") var err error var result int64 if unBindUser { result, err = services.BindUserIdToOpenUser(openUser.OpenId, entities.OPEN_USER_TYPE_QQ, user.Id) } //防止单个openuser 绑定多个user if nil == err && result > 0 { openUser.UserId = user.Id c.SetSession("openUser", openUser) } return } c.StringError(err.Error()) c.Data["name"] = user.Name c.Data["mail"] = user.Mail c.OauthRegister() }