Skip to content

Commit

Permalink
refactor: 로그아웃 구현 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
nayonsoso committed Dec 21, 2024
1 parent 6a7f683 commit 22827a3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package reviewme.auth.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseCookie;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -31,21 +28,6 @@ public ResponseEntity<Void> authWithGithub(
public ResponseEntity<Void> logout(
HttpServletRequest httpRequest
) {
HttpSession session = httpRequest.getSession(false);
if(session != null) {
session.invalidate();
}

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

return ResponseEntity
.noContent()
.header(HttpHeaders.SET_COOKIE, cookie.toString())
.build();
return ResponseEntity.noContent().build();
}
}
4 changes: 1 addition & 3 deletions backend/src/test/java/reviewme/api/AuthApiTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package reviewme.api;

import static org.hamcrest.Matchers.containsString;
import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName;
import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
Expand Down Expand Up @@ -55,7 +54,6 @@ public class AuthApiTest extends ApiTest {
.when().post("/v2/auth/logout")
.then().log().all()
.apply(handler)
.statusCode(204)
.header("Set-Cookie", containsString("JSESSIONID=; Path=/; Max-Age=0"));
.statusCode(204);
}
}

0 comments on commit 22827a3

Please sign in to comment.