Skip to content

Commit

Permalink
Merge pull request #25 from Soongsil-CoffeeChat/dev
Browse files Browse the repository at this point in the history
loginStatus 헤더에 추가
  • Loading branch information
KimKyoHwee authored May 28, 2024
2 parents fa55919 + ae8627a commit da83de2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit da83de2

Please sign in to comment.