优化一些逻辑。

This commit is contained in:
2026-08-06 17:45:06 +08:00
parent ea293f7866
commit ec1a19f469
5 changed files with 13 additions and 26 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ func JWTAuth() gin.HandlerFunc {
}
parts := strings.SplitN(authHeader, " ", 2)
if !(len(parts) == 2 && parts[0] == "Bearer") {
if len(parts) != 2 || parts[0] != "Bearer" {
c.JSON(http.StatusUnauthorized, gin.H{"error": "认证格式错误"})
c.Abort()
return