-
Notifications
You must be signed in to change notification settings - Fork 2
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
[BE] feat: 로그아웃 api 구현 #1121
[BE] feat: 로그아웃 api 구현 #1121
Conversation
HttpSession session = httpRequest.getSession(false); | ||
if (session != null) { | ||
session.invalidate(); | ||
} | ||
|
||
ResponseCookie cookie = ResponseCookie.from("JSESSIONID", "") | ||
.path("/") | ||
.maxAge(0) | ||
.secure(true) | ||
.httpOnly(true) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 어떻게 해결했나요 ?
1/ 서버에 저장되어있는 세션을 비활성화합니다.
2/ set-cookie 를 통해서 브라우저에 저장되어있는 쿠키까지 삭제합니다.
.statusCode(204) | ||
.header("Set-Cookie", containsString("JSESSIONID=; Path=/; Max-Age=0")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드에서 set cookie 로 브라우저의 쿠키를 삭제하는 것을 테스트하게 합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
초간단 구현 👍
sessionManager.saveReviewRequestCode(session, reviewRequestCode); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PostMapping("/v2/auth/logout") | ||
public ResponseEntity<Void> logout( | ||
HttpServletRequest httpRequest | ||
HttpServletRequest httpRequest, | ||
HttpServletResponse response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response 사용되지 않는데, 제거해도 되지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꼼꼼테드😎
# Conflicts: # backend/src/main/java/reviewme/auth/controller/AuthController.java # backend/src/test/java/reviewme/api/AuthApiTest.java
🚀 어떤 기능을 구현했나요 ?