From fbfe28a54e73fd20ee989a523692035a6d87d1c6 Mon Sep 17 00:00:00 2001 From: naiba Date: Thu, 9 Oct 2025 22:01:35 +0800 Subject: [PATCH] chore: back comp --- cmd/dashboard/controller/jwt.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/dashboard/controller/jwt.go b/cmd/dashboard/controller/jwt.go index 9054c408..8bcfe488 100644 --- a/cmd/dashboard/controller/jwt.go +++ b/cmd/dashboard/controller/jwt.go @@ -60,8 +60,17 @@ func payloadFunc() func(data any) jwt.MapClaims { func identityHandler() func(c *gin.Context) any { return func(c *gin.Context) any { claims := jwt.ExtractClaims(c) - userId := claims["user_id"].(string) - tokenIP := claims["ip"].(string) + + userId, ok := claims["user_id"].(string) + if !ok { + return nil + } + + tokenIP, ok := claims["ip"].(string) + if !ok { + return nil + } + currentIP := c.GetString(model.CtxKeyRealIPStr) if tokenIP != currentIP {