Skip to content

Commit 06a8f84

Browse files
committed
fix: 로그아웃 시 500 수정
1 parent f233dd0 commit 06a8f84

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/java/com/example/log4u/common/config/SecurityConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import com.example.log4u.common.oauth2.jwt.JwtAuthenticationFilter;
1919
import com.example.log4u.common.oauth2.jwt.JwtLogoutFilter;
2020
import com.example.log4u.common.oauth2.jwt.JwtUtil;
21-
import com.example.log4u.common.oauth2.repository.RefreshTokenRepository;
2221
import com.example.log4u.common.oauth2.service.CustomOAuth2UserService;
22+
import com.example.log4u.common.oauth2.service.RefreshTokenService;
2323
import com.example.log4u.domain.user.service.UserService;
2424

2525
import jakarta.servlet.http.HttpServletResponse;
@@ -33,7 +33,7 @@ public class SecurityConfig {
3333
private final OAuth2AuthenticationSuccessHandler oAuth2AuthenticationSuccessHandler;
3434
private final CustomOAuth2UserService customOAuth2UserService;
3535
private final UserService userService;
36-
private final RefreshTokenRepository refreshTokenRepository;
36+
private final RefreshTokenService refreshTokenService;
3737

3838
@Bean
3939
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws
@@ -48,7 +48,7 @@ public JwtAuthenticationFilter jwtAuthenticationFilter() {
4848

4949
@Bean
5050
public JwtLogoutFilter jwtLogoutFilter() {
51-
return new JwtLogoutFilter(jwtUtil, refreshTokenRepository);
51+
return new JwtLogoutFilter(jwtUtil, refreshTokenService);
5252
}
5353

5454
@Bean
@@ -66,7 +66,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
6666
.successHandler(oAuth2AuthenticationSuccessHandler)
6767
)
6868
.addFilterBefore(new JwtAuthenticationFilter(jwtUtil, userService), OAuth2LoginAuthenticationFilter.class)
69-
.addFilterBefore(new JwtLogoutFilter(jwtUtil, refreshTokenRepository), LogoutFilter.class)
69+
.addFilterBefore(new JwtLogoutFilter(jwtUtil, refreshTokenService), LogoutFilter.class)
7070
.logout(AbstractHttpConfigurer::disable)
7171
.exceptionHandling(exceptions -> exceptions
7272
.authenticationEntryPoint((request, response, authException) -> {

src/main/java/com/example/log4u/common/oauth2/jwt/JwtLogoutFilter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import org.springframework.web.filter.GenericFilterBean;
99

10-
import com.example.log4u.common.oauth2.repository.RefreshTokenRepository;
10+
import com.example.log4u.common.oauth2.service.RefreshTokenService;
1111
import com.example.log4u.common.util.CookieUtil;
1212

1313
import io.jsonwebtoken.ExpiredJwtException;
@@ -24,7 +24,7 @@
2424
public class JwtLogoutFilter extends GenericFilterBean {
2525

2626
private final JwtUtil jwtUtil;
27-
private final RefreshTokenRepository refreshTokenRepository;
27+
private final RefreshTokenService refreshTokenService;
2828
private static final String REFRESH_TOKEN_EXPIRED_JSON_MSG = "{\"message\": \"토큰이 존재하지 않습니다.\"}";
2929

3030
@Override
@@ -108,7 +108,7 @@ private boolean validateTokenExpiration(
108108
}
109109

110110
// 리프레시 토큰이 DB에 없는 경우
111-
Boolean isExist = refreshTokenRepository.existsByRefresh(refresh);
111+
Boolean isExist = refreshTokenService.existsByRefresh(refresh);
112112
if (Boolean.FALSE.equals(isExist)) {
113113
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
114114
return false;
@@ -132,7 +132,7 @@ private String extractRefreshTokenFromCookie(HttpServletRequest request) {
132132

133133
public void logout(HttpServletResponse response, String refresh) throws IOException {
134134
// DB 에서 리프레시 토큰 제거
135-
refreshTokenRepository.deleteByRefresh(refresh);
135+
refreshTokenService.deleteRefreshToken(refresh);
136136
// 쿠키 제거
137137
CookieUtil.deleteCookie(response, ACCESS_TOKEN);
138138
CookieUtil.deleteCookie(response, REFRESH_TOKEN);

0 commit comments

Comments
 (0)