fix: check user status when validating token (#23)

This commit is contained in:
JustSong
2023-04-27 15:05:33 +08:00
parent 9667bc86bc
commit f820158ee5
2 changed files with 23 additions and 0 deletions
+10
View File
@@ -98,6 +98,16 @@ func TokenAuth() func(c *gin.Context) {
c.Abort()
return
}
if !model.IsUserEnabled(token.UserId) {
c.JSON(http.StatusOK, gin.H{
"error": gin.H{
"message": "用户已被封禁",
"type": "one_api_error",
},
})
c.Abort()
return
}
c.Set("id", token.UserId)
c.Set("token_id", token.Id)
c.Set("unlimited_times", token.UnlimitedTimes)