huangjiajun 2 months ago
parent
commit
64b4f02e0a
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      app/svc/svc_default_user.go

+ 8
- 3
app/svc/svc_default_user.go View File

@@ -89,7 +89,7 @@ func FastLoginUserExist(c *gin.Context, r *md.LoginResponse, requestBody *md.Fas
_ = logx.Warn(err)
return e.NewErr(400000, "数据不完整")
}
token := CheckUserToken(c, user.Uid, user.Username, user.Phone, appName)
token := CheckUserToken(c, user, appName)
r.Token = token
r.UserID = utils.IntToStr(user.Uid)
r.UserName = requestBody.Mobile
@@ -108,12 +108,17 @@ func FastLoginUserExist(c *gin.Context, r *md.LoginResponse, requestBody *md.Fas
}
return nil
}
func CheckUserToken(c *gin.Context, uid int, username, phone, appName string) string {
profile, err := db.UserProfileFindByID(db.DBs[c.GetString("mid")], uid)
func CheckUserToken(c *gin.Context, user *model.User, appName string) string {
profile, err := db.UserProfileFindByID(db.DBs[c.GetString("mid")], user.Uid)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
return ""
}
token := profile.ArkidToken
// parts[1]是token
_, err = utils.ParseToken(token)
if err != nil {
token, _ = utils.GenToken(user.Uid, user.Username, user.Phone, appName, "", "")
}
return token
}

Loading…
Cancel
Save