diff --git a/src/main/java/com/example/howmuch/service/user/AuthService.java b/src/main/java/com/example/howmuch/service/user/AuthService.java index fdf4e96..4c38710 100644 --- a/src/main/java/com/example/howmuch/service/user/AuthService.java +++ b/src/main/java/com/example/howmuch/service/user/AuthService.java @@ -26,8 +26,8 @@ public class AuthService { private final UserService userService; private final OauthService oauthService; - @Transactional /* jwt 만료시 access token 재발급 해주는 메소드 with 만료된 access token + refresh token */ + @Transactional public UserOauthLoginResponseDto accessTokenByRefreshToken(String accessToken, String refreshToken) { // 1. refresh token 유효성 this.validationRefreshToken(refreshToken); diff --git a/src/main/java/com/example/howmuch/util/JwtService.java b/src/main/java/com/example/howmuch/util/JwtService.java index 237db16..1f00c79 100644 --- a/src/main/java/com/example/howmuch/util/JwtService.java +++ b/src/main/java/com/example/howmuch/util/JwtService.java @@ -65,6 +65,7 @@ public String getPayLoad(String token) { .getBody() .getSubject(); } catch (ExpiredJwtException e) { + // accessToken 이 만료된 경우 또한 userId 반환 return e.getClaims().getSubject(); } catch (JwtException e) { throw new UnauthorizedUserException("로그인이 필요합니다."); diff --git a/src/main/java/com/example/howmuch/util/SecurityUtil.java b/src/main/java/com/example/howmuch/util/SecurityUtil.java index b419d42..d39f7eb 100644 --- a/src/main/java/com/example/howmuch/util/SecurityUtil.java +++ b/src/main/java/com/example/howmuch/util/SecurityUtil.java @@ -23,4 +23,8 @@ public static Collection getUserNickname() { = (UserAuthentication) SecurityContextHolder.getContext().getAuthentication(); return authentication.getAuthorities(); } + + public static void clearSecurityContext() { + SecurityContextHolder.clearContext(); + } }