sunsheng 8 months ago
parent
commit
42e945d44d
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/api/jwt.go

+ 4 - 1
src/api/jwt.go

@@ -8,6 +8,7 @@ import (
 
 	jwt "github.com/appleboy/gin-jwt/v2"
 	"github.com/gin-gonic/gin"
+	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
 var identityKey = "id"
@@ -63,7 +64,9 @@ func NewUitlsJwt(app *conf.AppConf) *UtilsJwt {
 
 		Authorizator: func(data interface{}, _ *gin.Context) bool {
 			u := data.(*JWTUser)
-			return len(u.ID) > 0
+			uid, _ := primitive.ObjectIDFromHex(u.ID)
+
+			return !uid.IsZero()
 		},
 
 		LoginResponse: func(c *gin.Context, status int, token string, expire time.Time) {