Skip to content

Commit

Permalink
[fix] 재발급, 로그아웃 컨트롤러 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchoGreenT committed Oct 21, 2023
1 parent 747f3c2 commit 9f30539
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,32 @@ public TokenResponseDto kakaoLogin(HttpServletRequest request) {

return reissueTokenResponseDto;
}

@DeleteMapping("/logout")
public ResponseDto logout(HttpServletRequest request) {


String userId = jwtTokenProvider.getUserId(request);

ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId));

LOGGER.info("로그아웃 완료");

return logoutResponseDto;
}

@GetMapping(value = "/reissue-token")
public TokenResponseDto reissueToken(HttpServletRequest request) {

String userId = jwtTokenProvider.getUserId(request);
String refreshToken = jwtTokenProvider.resolveToken(request);

TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId));

LOGGER.info("토큰 재발급 완료");

return reissueTokenResponseDto;
}
//
// @DeleteMapping("/logout")
// public ResponseDto logout(HttpServletRequest request) {
//
//
// String userId = jwtTokenProvider.getUserId(request);
//
// ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId));
//
// LOGGER.info("로그아웃 완료");
//
// return logoutResponseDto;
// }
//
// @GetMapping(value = "/reissue-token")
// public TokenResponseDto reissueToken(HttpServletRequest request) {
//
// String userId = jwtTokenProvider.getUserId(request);
// String refreshToken = jwtTokenProvider.resolveToken(request);
//
// TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId));
//
// LOGGER.info("토큰 재발급 완료");
//
// return reissueTokenResponseDto;
// }

@PostMapping(value = "/google-login")
public TokenResponseDto googleLogin(HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package modernfarmer.server.farmususer.user.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import modernfarmer.server.farmususer.user.dto.response.ResponseDto;
import modernfarmer.server.farmususer.user.dto.response.TokenResponseDto;
import modernfarmer.server.farmususer.user.service.AuthService;
import modernfarmer.server.farmususer.user.util.JwtTokenProvider;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/api/user")
@RequiredArgsConstructor
public class UserController {

private final AuthService authService;
private final JwtTokenProvider jwtTokenProvider;


@DeleteMapping("/logout")
public ResponseDto logout(HttpServletRequest request) {


String userId = jwtTokenProvider.getUserId(request);

ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId));

log.info("로그아웃 완료");

return logoutResponseDto;
}

@GetMapping(value = "/reissue-token")
public TokenResponseDto reissueToken(HttpServletRequest request) {

String userId = jwtTokenProvider.getUserId(request);
String refreshToken = jwtTokenProvider.resolveToken(request);

TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId));

log.info("토큰 재발급 완료");

return reissueTokenResponseDto;
}
}

0 comments on commit 9f30539

Please sign in to comment.