huangjiajun 1 month ago
parent
commit
781e2980ab
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      app/svc/svc_default_user.go

+ 6
- 1
app/svc/svc_default_user.go View File

@@ -115,10 +115,15 @@ func CheckUserToken(c *gin.Context, user *model.User, appName string) string {
return "" return ""
} }
token := profile.ArkidToken token := profile.ArkidToken
// parts[1]是token
_, err = utils.ParseToken(token) _, err = utils.ParseToken(token)
if err != nil { if err != nil {
token, _ = utils.GenToken(user.Uid, user.Username, user.Phone, appName, "", "") token, _ = utils.GenToken(user.Uid, user.Username, user.Phone, appName, "", "")
// 更新
profile.ArkidToken = token
_, err = db.UserProfileUpdate(db.DBs[c.GetString("mid")], user.Uid, profile)
// 写入缓存
key := fmt.Sprintf("%s:token:%s", c.GetString("mid"), user.Username)
_, err = cache.SetEx(key, token, 39528000) // 半年
} }
return token return token
} }

Loading…
Cancel
Save