From 34cbd8375f3048a88a1f83c042632b5b19d13270 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 14 二月 2024 19:22:15 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/security/JwtAuthenticationFilter.java | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/security/JwtAuthenticationFilter.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/security/JwtAuthenticationFilter.java index d6752dd..91b8954 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/security/JwtAuthenticationFilter.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/security/JwtAuthenticationFilter.java @@ -37,7 +37,7 @@ @Component public class JwtAuthenticationFilter extends OncePerRequestFilter { - public static final ArrayList<String> WHITE_KEY = new ArrayList<String>(){ + public static final ArrayList<String> WHITE_LIST = new ArrayList<String>(){ private static final long serialVersionUID = 1L; { add("xltys1995"); @@ -63,8 +63,9 @@ if (!Cools.isEmpty(access_token)) { try { User user; - if (WHITE_KEY.contains(access_token)) { - user = userService.getByUsername("openapi", 2L); + // 鐧藉悕鍗� + if (WHITE_LIST.contains(access_token)) { + user = userService.getByUsername("root", 1L); if (user == null) { throw new UsernameNotFoundException("Username not found"); } @@ -77,7 +78,7 @@ // 瑙f瀽token Claims claims = JwtUtil.parseToken(access_token, configProperties.getTokenKey()); JwtSubject jwtSubject = JwtUtil.getJwtSubject(claims); - user = userService.getByUsername(jwtSubject.getUsername(), jwtSubject.getTenantId()); + user = userService.getByUsername(jwtSubject.getUsername(), jwtSubject.getHostId()); if (user == null) { throw new UsernameNotFoundException("Username not found"); } @@ -92,15 +93,16 @@ String token = JwtUtil.buildToken(jwtSubject, configProperties.getTokenExpireTime(), configProperties.getTokenKey()); response.addHeader(Constants.TOKEN_HEADER_NAME, token); - userLoginService.saveAsync(user.getId(), UserLogin.TYPE_REFRESH, null, - user.getHostId(), request); + userLoginService.saveAsync(user.getId(), UserLogin.TYPE_REFRESH, null, user.getHostId(), request); } } } catch (ExpiredJwtException e) { + e.printStackTrace(); HttpUtils.responseError(response, Constants.TOKEN_EXPIRED_CODE, Constants.TOKEN_EXPIRED_MSG, e.getMessage()); return; } catch (Exception e) { + e.printStackTrace(); HttpUtils.responseError(response, Constants.BAD_CREDENTIALS_CODE, Constants.BAD_CREDENTIALS_MSG, e.toString()); return; -- Gitblit v1.9.1