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

[BE] feat: 로그아웃 api 구현 #1121

Merged
merged 5 commits into from
Feb 17, 2025
Merged

[BE] feat: 로그아웃 api 구현 #1121

merged 5 commits into from
Feb 17, 2025

Conversation

nayonsoso
Copy link
Contributor


🚀 어떤 기능을 구현했나요 ?

  • 로그아웃 api 를 구현했습니다.

Copy link

github-actions bot commented Feb 16, 2025

Test Results

197 tests  ±0   194 ✅ ±0   6s ⏱️ -1s
 73 suites ±0     3 💤 ±0 
 73 files   ±0     0 ❌ ±0 

Results for commit a5d91c4. ± Comparison against base commit 06bd5d4.

♻️ This comment has been updated with latest results.

Comment on lines +53 to +63
HttpSession session = httpRequest.getSession(false);
if (session != null) {
session.invalidate();
}

ResponseCookie cookie = ResponseCookie.from("JSESSIONID", "")
.path("/")
.maxAge(0)
.secure(true)
.httpOnly(true)
.build();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 어떻게 해결했나요 ?

1/ 서버에 저장되어있는 세션을 비활성화합니다.
2/ set-cookie 를 통해서 브라우저에 저장되어있는 쿠키까지 삭제합니다.

Comment on lines +55 to +56
.statusCode(204)
.header("Set-Cookie", containsString("JSESSIONID=; Path=/; Max-Age=0"));
Copy link
Contributor Author

@nayonsoso nayonsoso Feb 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 코드에서 set cookie 로 브라우저의 쿠키를 삭제하는 것을 테스트하게 합니다.

Copy link
Contributor

@Kimprodp Kimprodp left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response 사용되지 않는데, 제거해도 되지 않을까요?

Copy link
Contributor Author

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
@nayonsoso nayonsoso merged commit 298a1df into develop Feb 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] 로그아웃을 구현한다.
2 participants