func (c *UserController) commonCreateUser() { var user entities.User user.Name = c.GetString("name") user.Mail = c.GetString("mail") user.Nick = user.Name user.Password = c.GetString("password") captcha := c.GetString("captcha") var err error isCaptchaValid := c.isMailCaptchaValid(captcha) if !isCaptchaValid { err = errors.New("验证码错误") } else { err = services.SaveUser(&user) } if err != nil { c.StringError(err.Error()) c.Data["name"] = user.Name c.Data["mail"] = user.Mail c.Register() } c.SetCurrSession("user", user) c.Ctx.Redirect(302, "/") }
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() }