Skip to content

Commit

Permalink
Merge pull request #21 from Soongsil-CoffeeChat/ref/#18
Browse files Browse the repository at this point in the history
access token, refresh token 발급 로직 수정
  • Loading branch information
KimKyoHwee authored May 25, 2024
2 parents 82bb823 + 51c3f99 commit ae987a2
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 ae987a2

Please sign in to comment.