Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loginStatus 헤더에 추가 #25

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RefreshTokenController(JWTUtil jwtUtil, RefreshTokenService refreshTokenS

@PostMapping("/reissue")
@Operation(summary="리프레쉬 토큰으로 액세스 토큰 reissue")
@ApiResponse(responseCode = "200", description = "액세스토큰 재발급")
@ApiResponse(responseCode = "200", description = "헤더 : access, refresh, loginStatus")
public ResponseEntity<?> reissue(HttpServletRequest request, HttpServletResponse response){
return refreshTokenService.reissueByRefreshToken(request, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ private void addRefreshEntity(String username, String refresh, Long expiredMs) {
public ResponseEntity<?> reissueByRefreshToken(HttpServletRequest request, HttpServletResponse response) {
//get refresh token
String refresh = null;
String loginStatus=null;
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {

if (cookie.getName().equals("loginStatus")){
loginStatus=cookie.getValue();
}
if (cookie.getName().equals("refresh")) {
refresh = cookie.getValue();
System.out.println("refresh = " + refresh);
Expand Down Expand Up @@ -107,6 +110,7 @@ public ResponseEntity<?> reissueByRefreshToken(HttpServletRequest request, HttpS
//response
response.setHeader("access", newAccess);
response.setHeader("refresh", newRefresh);
response.setHeader("loginStatus", loginStatus);
response.addCookie(createCookie("refresh", newRefresh));

return new ResponseEntity<>(HttpStatus.OK);
Expand Down
Loading