修正了登录1
This commit is contained in:
+23
-10
@@ -32,6 +32,11 @@ func (r *Login) Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.OpenId == "" && req.Mobile == "" {
|
||||
responses.FailWithMessage("登陆失败", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
@@ -47,21 +52,29 @@ func (r *Login) Login(c *gin.Context) {
|
||||
// 检测用户信息
|
||||
userDao := dao.UserDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["mobile"] = req.Mobile
|
||||
if req.OpenId != "" {
|
||||
maps["open_id"] = req.OpenId
|
||||
}
|
||||
|
||||
if req.Mobile != "" {
|
||||
maps["mobile"] = req.Mobile
|
||||
}
|
||||
user, _ := userDao.GetUser(maps)
|
||||
// 新用户处理方式
|
||||
if user == nil {
|
||||
// 检测验证码
|
||||
if config.C.Env != "dev" {
|
||||
code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result()
|
||||
if code == "" {
|
||||
responses.FailWithMessage("验证码失效", c)
|
||||
return
|
||||
}
|
||||
if req.Mobile != "" {
|
||||
if config.C.Env != "dev" {
|
||||
code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result()
|
||||
if code == "" {
|
||||
responses.FailWithMessage("验证码失效", c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Code != code {
|
||||
responses.FailWithMessage("验证码错误", c)
|
||||
return
|
||||
if req.Code != code {
|
||||
responses.FailWithMessage("验证码错误", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user