From f6bc28000e08839e30112f012e13f66f25d5e7c2 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 29 Jul 2021 17:32:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=94=99=E8=AF=AFtoken?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E8=A7=A3=E6=9E=90=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/web/service/TokenService.java | 18 ++++++++++++------ ruoyi-ui/src/utils/request.js | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java index 943eae2..5b4c414 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -60,12 +60,18 @@ public class TokenService String token = getToken(request); if (StringUtils.isNotEmpty(token)) { - Claims claims = parseToken(token); - // 解析对应的权限以及用户信息 - String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); - String userKey = getTokenKey(uuid); - LoginUser user = redisCache.getCacheObject(userKey); - return user; + try + { + Claims claims = parseToken(token); + // 解析对应的权限以及用户信息 + String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); + String userKey = getTokenKey(uuid); + LoginUser user = redisCache.getCacheObject(userKey); + return user; + } + catch (Exception e) + { + } } return null; } diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index 6a7cbfa..b9b5ad8 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -64,7 +64,7 @@ service.interceptors.response.use(res => { location.href = '/index'; }) }).catch(() => {}); - return Promise.reject('error') + return Promise.reject() } else if (code === 500) { Message({ message: msg,