From da760270ca46f51bdaa9080089c14f1d01eebbc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F=E4=B9=90?= Date: Wed, 30 Aug 2023 14:50:55 +0800 Subject: [PATCH] x --- middleware/jwt/jwt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware/jwt/jwt.go b/middleware/jwt/jwt.go index ebb444d..d7f1029 100644 --- a/middleware/jwt/jwt.go +++ b/middleware/jwt/jwt.go @@ -70,7 +70,7 @@ func JWT(opts ...JwtOption) middleware.Middleware { if err != nil { return err } - if needAuth && userInfo.UserId == 0 { + if needAuth && userInfo.UserId == "" { return errors.Unauthorized("TOKEN_BAD", "") } if authKey != "" { @@ -78,7 +78,7 @@ func JWT(opts ...JwtOption) middleware.Middleware { return err } } - if userInfo.UserId > 0 { + if userInfo.UserId != "" { ctx = SetUserContext(ctx, userInfo) } return nil