-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
747f3c2
commit 9f30539
Showing
2 changed files
with
77 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |