Skip to content

Commit

Permalink
access token, refresh token 발급 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
김교휘 authored and 김교휘 committed May 25, 2024
1 parent d379f73 commit 51c3f99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
String refreshToken = jwtUtil.createJwt("refresh", username, role, 86400000L); //24시간
//Refresh 토큰 저장
addRefreshEntity(username, refreshToken, 86400000L);
//Access토큰은 헤더에, Refresh 토큰은 쿠키에 담아 보내기
response.setHeader("access", accessToken);
//Access토큰은 헤더에, Refresh 토큰은 쿠키에 담아 보내기 (리프레쉬 토큰만 넣은 후 reissue에서 액세스 토큰 발급)
//response.setHeader("access", accessToken);
response.addCookie(createCookie("refresh", refreshToken));

//login status넣어주기
if (role.equals("ROLE_USER"))
response.setHeader("loginStatus", "signup");
response.addCookie(createCookie("loginStatus", "signup"));
else if (role.equals("ROLE_MENTEE") || role.equals("ROLE_MENTOR"))
response.setHeader("loginStatus", "main");
response.addCookie(createCookie("loginStatus", "main"));
//가입필요 : 추가정보 가입 request넣어줘야함 가입완료 : 발급받은 토큰으로 요청보내면됨

response.setStatus(HttpStatus.OK.value()); //200으로 프론트에 반환쳐주기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public ResponseEntity<?> reissueByRefreshToken(HttpServletRequest request, HttpS

//response
response.setHeader("access", newAccess);
response.addCookie(createCookie("refresh", newRefresh));
response.setHeader("refresh", newRefresh);
//response.addCookie(createCookie("refresh", newRefresh));

return new ResponseEntity<>(HttpStatus.OK);

Expand Down

0 comments on commit 51c3f99

Please sign in to comment.