🐛 resolve interface validation issues

This commit is contained in:
landaiqing
2024-09-05 17:06:10 +08:00
parent 2eb9c3ac68
commit 01305c2fa7
10 changed files with 68 additions and 89 deletions

View File

@@ -498,3 +498,35 @@ func getUserLoginDevice(user model.ScaAuthUser, c *gin.Context) bool {
return true
}
// Logout 退出登录
// @Summary 退出登录
// @Tags 用户模块
// @Success 200 {string} json
// @Router /api/auth/user/logout [post]
func (UserAPI) Logout(c *gin.Context) {
userId := c.Query("user_id")
if userId == "" {
global.LOG.Errorln("userId is empty")
result.FailWithMessage(ginI18n.MustGetMessage(c, "ParamsError"), c)
return
}
tokenKey := constant.UserLoginTokenRedisKey + userId
del := redis.Del(tokenKey)
if del.Err() != nil {
global.LOG.Errorln(del.Err())
result.FailWithMessage(ginI18n.MustGetMessage(c, "LogoutFailed"), c)
return
}
ip := utils.GetClientIP(c)
key := constant.UserLoginClientRedisKey + ip
del = redis.Del(key)
if del.Err() != nil {
global.LOG.Errorln(del.Err())
result.FailWithMessage(ginI18n.MustGetMessage(c, "LogoutFailed"), c)
return
}
result.OkWithMessage(ginI18n.MustGetMessage(c, "LogoutSuccess"), c)
}