From 48467740fa3144b073f9b679c3a9764f75e206b1 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期五, 26 四月 2024 18:25:04 +0800
Subject: [PATCH] 最新版本

---
 server/system_gateway/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/server/system_gateway/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java b/server/system_gateway/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java
index 460b974..1faef7c 100644
--- a/server/system_gateway/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java
+++ b/server/system_gateway/src/main/java/com/doumee/config/jwt/JwtTokenUtil.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.doumee.core.model.LoginUserInfo;
+import com.doumee.core.utils.Constants;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.SignatureAlgorithm;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -96,7 +97,7 @@
             claims.setLoginDate(new Date());
             refreshedToken = generateTokenDo(claims);
             if(refreshedToken!=null){
-                redisTemplate.delete(token);//鍒犻櫎鑰佺殑token
+                redisTemplate.delete(Constants.REDIS_TOKEN_KEY+token);//鍒犻櫎鑰佺殑token
             }
         } catch (Exception e) {
             refreshedToken = null;
@@ -131,7 +132,7 @@
                 .setExpiration(expirationDate)
                 .signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret())
                 .compact();
-        redisTemplate.opsForValue().set(token,JSONObject.toJSONString(userInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS);
+        redisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+token,JSONObject.toJSONString(userInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS);
         return token;
     }
 
@@ -144,7 +145,7 @@
     private LoginUserInfo getClaimsFromToken(String token) {
         LoginUserInfo claims;
         try {
-            String userInfo = (String) redisTemplate.opsForValue().get(token);
+            String userInfo = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY+token);
             claims = JSONObject.toJavaObject(JSONObject.parseObject(userInfo),LoginUserInfo.class);
         } catch (Exception e) {
             claims = null;

--
Gitblit v1.9.3