Skip to content

Commit

Permalink
Hotfix: JWT 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KoungQ committed Aug 20, 2024
1 parent a4f315d commit f2b8dc4
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,20 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
public void checkAccessTokenAndRefreshToken(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain, String refreshToken) throws ServletException, IOException {
log.info("checkAccessTokenAndRefreshToken() 호출");
jwtService.extractAccessToken(request)

String accessToken = jwtService.extractAccessToken(request)
.filter(jwtService::isTokenValid)
.ifPresentOrElse(
accessToken -> jwtService.extractEmail(accessToken)
.ifPresent(email -> userRepository.findByEmail(email)
.ifPresent(user -> {
saveAuthentication(user);
try {
filterChain.doFilter(request, response);
} catch (IOException | ServletException e) {
throw new RuntimeException(e);
}
})),
() -> checkRefreshTokenAndReIssueAccessToken(response, refreshToken)
);
.orElse(null);

filterChain.doFilter(request, response);
if (accessToken == null) {
checkRefreshTokenAndReIssueAccessToken(response, refreshToken);
} else {
jwtService.extractEmail(accessToken)
.ifPresent(email -> userRepository.findByEmail(email)
.ifPresent(this::saveAuthentication));

filterChain.doFilter(request, response);
}
}

public void checkRefreshTokenAndReIssueAccessToken(HttpServletResponse response, String refreshToken) {
Expand Down

0 comments on commit f2b8dc4

Please sign in to comment.