From f8c25d1fab78aa4e0a6bdb10f91e61698af434c4 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期五, 01 七月 2022 14:34:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java
index 874b46f..a6ba791 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService;
+import com.gkhy.safePlatform.commons.co.CacheAuthority;
 import com.gkhy.safePlatform.commons.co.CacheUser;
 import com.gkhy.safePlatform.commons.enums.RedisKeyEnum;
 import com.gkhy.safePlatform.commons.enums.ResultCodes;
@@ -54,11 +55,7 @@
         } catch (BusinessException e) {
             // 返回异常
             this.writeJSON(req, resp, new ResultVO<>(e.getError()));
-        } catch (Exception e) {
-            e.printStackTrace();
-            this.writeJSON(req, resp, new ResultVO<>(ResultCodes.SERVER_ERROR));
         }
-
 
     }
 
@@ -93,13 +90,15 @@
                 // 3.redis获取权限
                 String authoritiesKey = RedisKeyEnum.authKey(RedisKeyEnum.AUTH_AUTHORITIES, userId);
                 String oo = userAccountService.getValueByKeyFromRedis(authoritiesKey);
-                List<GrantedAuthority> authorities;
+                List<GrantedAuthority> authorities = new ArrayList<>();
                 // 4.redis中是否存在
                 if (oo != null) {
                     // 5.存在
-                    authorities = JSONArray.parseArray(oo, GrantedAuthority.class);
+                    List<CacheAuthority> cacheAuthorities = JSONArray.parseArray(oo, CacheAuthority.class);
+                    for (CacheAuthority cacheAuthority: cacheAuthorities) {
+                        authorities.add(new SimpleGrantedAuthority(cacheAuthority.getAuthority()));
+                    }
                 }else {
-                    authorities = new ArrayList<>();
                     // 6.不存在=>数据库查询
                     String roleCode = userAccountService.getUserRoleCodeByUserId(userId);
                     // role

--
Gitblit v1.9.2