Merge remote-tracking branch 'origin/main'

# Conflicts:
#	controller/relay.go
#	main.go
#	middleware/distributor.go
This commit is contained in:
CaIon
2023-09-09 03:15:55 +08:00
26 changed files with 1027 additions and 187 deletions

View File

@@ -109,7 +109,18 @@ func TokenAuth() func(c *gin.Context) {
c.Abort()
return
}
if !model.CacheIsUserEnabled(token.UserId) {
userEnabled, err := model.IsUserEnabled(token.UserId)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": gin.H{
"message": err.Error(),
"type": "one_api_error",
},
})
c.Abort()
return
}
if !userEnabled {
c.JSON(http.StatusForbidden, gin.H{
"error": gin.H{
"message": "用户已被封禁",