From 84560eab857f3cc1c4ee6bd4bd8608830aceecdc Mon Sep 17 00:00:00 2001
From: songhuangfeng123 <shf18767906695@163.com>
Date: Mon, 04 Jul 2022 13:57:47 +0800
Subject: [PATCH] Merge branches 'genchuang' and 'master' of https://sinanoaq.cn:8888/r/safePlatform-out into genchuang
---
safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 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..ae3b0f6 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
@@ -2,7 +2,9 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
+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;
@@ -36,7 +38,7 @@
@Autowired
private TokenConfig tokenConfig;
@DubboReference(check = false)
- private UserAccountService userAccountService;
+ private AccountAuthService userAccountService;
@@ -54,11 +56,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 +91,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