优化一些逻辑。
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user