From 3f2d9bb3cfd67d61c965c7c5345c40d3e4271a09 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 23 八月 2024 14:33:17 +0800
Subject: [PATCH] 合并代码

---
 ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
index 8128e68..1e5df74 100644
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
@@ -39,7 +39,7 @@
 	// 排除过滤的 uri 地址,nacos自行添加
 	@Autowired
 	private IgnoreWhiteProperties ignoreWhite;
-	
+
 	@Autowired
 	private RedisService redisService;
 	
@@ -98,7 +98,7 @@
 	}
 	
 	private Mono<Void> unauthorizedResponse(ServerWebExchange exchange, String msg) {
-		log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
+		log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath() + "\n" + msg);
 		return ServletUtils.webFluxResponseWriter(exchange.getResponse(), msg, HttpStatus.UNAUTHORIZED);
 	}
 	
@@ -144,7 +144,7 @@
 		if(null == cacheMap){
 			cacheMap = new HashMap<>();
 			cacheMap.put(url, timestamp);
-			redisService.setCacheMap(client, cacheMap);
+			redisService.setCacheMap(client, cacheMap, 5L);
 		}else{
 			Object o = cacheMap.get(url);
 			if(null == o){
@@ -159,7 +159,7 @@
 					cacheMap.put(url, timestamp);
 				}
 			}
-			redisService.setCacheMap(client, cacheMap);
+			redisService.setCacheMap(client, cacheMap, 5L);
 		}
 	}
 	
@@ -179,14 +179,8 @@
 		if (claims == null) {
 			throw new RuntimeException("令牌已过期或验证不正确!");
 		}
-//		String userkey = JwtUtils.getUserKey(claims);
-//		boolean islogin = redisService.hasKey(getTokenKey(userkey));
-//		if (!islogin) {
-//			throw new RuntimeException("登录状态已过期");
-//		}
 		String userid = JwtUtils.getUserId(claims);
-		String username = JwtUtils.getUserName(claims);
-		if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
+		if (StringUtils.isEmpty(userid)) {
 			throw new RuntimeException("令牌验证失败");
 		}
 	}

--
Gitblit v1.7.1