|
|
@@ -115,10 +115,15 @@ func CheckUserToken(c *gin.Context, user *model.User, appName string) string { |
|
|
|
return "" |
|
|
|
} |
|
|
|
token := profile.ArkidToken |
|
|
|
// parts[1]是token |
|
|
|
_, err = utils.ParseToken(token) |
|
|
|
if err != nil { |
|
|
|
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 |
|
|
|
} |