Skip to content

Commit

Permalink
fix: 로그아웃 RequestDTO 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
limjustin committed Feb 15, 2024
1 parent 09939ab commit bff0dd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/main/java/umc/meme/auth/global/auth/AuthController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package umc.meme.auth.global.auth;

import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -34,8 +35,11 @@ public BaseResponseDto<?> reissue(@RequestBody AuthRequest.ReissueDto reissueDto
}

@PostMapping("/api/v1/auth/logout")
public BaseResponseDto<?> logout(@RequestHeader("Authorization") AuthRequest.AccessTokenDto requestAccessTokenDto) {
authService.logout(requestAccessTokenDto);
public BaseResponseDto<?> logout(HttpServletRequest request) {
System.out.println(request);
System.out.println(request.getHeader("Authorization"));
String header = request.getHeader("Authorization");
authService.logout(header);
return BaseResponseDto.SuccessResponse(SuccessStatus.LOGOUT_SUCCESS);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/umc/meme/auth/global/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ public AuthResponse.TokenDto reissue(AuthRequest.ReissueDto reissueDto) {
}

@Transactional
public void logout(AuthRequest.AccessTokenDto requestAccessTokenDto) {
String requestAccessToken = resolveToken(requestAccessTokenDto.getAccessToken());
public void logout(String header) {
String requestAccessToken = resolveToken(header);
deleteRefreshToken(requestAccessToken);
SecurityContextHolder.clearContext();
}

@Transactional
public void withdraw(AuthRequest.AccessTokenDto requestAccessTokenDto) {
logout(requestAccessTokenDto);
// logout(requestAccessTokenDto);
String requestAccessToken = resolveToken(requestAccessTokenDto.getAccessToken());
String username = (String) jwtTokenProvider.getClaims(requestAccessToken).get("username");
User user = userRepository.findByUsername(username)
Expand Down

0 comments on commit bff0dd3

Please sign in to comment.