diff --git a/backend/src/main/java/kr/momo/controller/CookieManager.java b/backend/src/main/java/kr/momo/controller/CookieManager.java index 3a7ead6a0..7720fad45 100644 --- a/backend/src/main/java/kr/momo/controller/CookieManager.java +++ b/backend/src/main/java/kr/momo/controller/CookieManager.java @@ -8,14 +8,15 @@ public class CookieManager { private static final String ACCESS_TOKEN = "ACCESS_TOKEN"; private static final String SAME_SITE_OPTION = "None"; + private static final long SESSION_COOKIE_AGE = -1; private static final long EXPIRED_COOKIE_AGE = 0; - public String createNewCookie(String value, String uuid, long maxAge) { - return createCookie(value, buildPath(uuid), maxAge); + public String createNewCookie(String value, String path) { + return createCookie(value, path, SESSION_COOKIE_AGE); } - public String createExpiredCookie(String uuid) { - return createCookie("", buildPath(uuid), EXPIRED_COOKIE_AGE); + public String createExpiredCookie(String path) { + return createCookie("", path, EXPIRED_COOKIE_AGE); } private String createCookie(String value, String path, long maxAge) { @@ -28,8 +29,4 @@ private String createCookie(String value, String path, long maxAge) { .build() .toString(); } - - private String buildPath(String uuid) { - return String.format("/meeting/%s", uuid); - } } diff --git a/backend/src/main/java/kr/momo/controller/attendee/AttendeeController.java b/backend/src/main/java/kr/momo/controller/attendee/AttendeeController.java index 7df5ad5b8..8280eeb4d 100644 --- a/backend/src/main/java/kr/momo/controller/attendee/AttendeeController.java +++ b/backend/src/main/java/kr/momo/controller/attendee/AttendeeController.java @@ -18,8 +18,6 @@ @RequiredArgsConstructor public class AttendeeController { - private static final long SESSION_COOKIE_AGE = -1; - private final AttendeeService attendeeService; private final CookieManager cookieManager; @@ -28,7 +26,8 @@ public ResponseEntity> login( @PathVariable String uuid, @RequestBody @Valid AttendeeLoginRequest request ) { AttendeeLoginResponse response = attendeeService.login(uuid, request); - String cookie = cookieManager.createNewCookie(response.token(), uuid, SESSION_COOKIE_AGE); + String path = String.format("/meeting/%s", uuid); + String cookie = cookieManager.createNewCookie(response.token(), path); return ResponseEntity.ok() .header(HttpHeaders.SET_COOKIE, cookie) diff --git a/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java b/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java index f3e4a4fce..cd6723375 100644 --- a/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java +++ b/backend/src/main/java/kr/momo/controller/meeting/MeetingController.java @@ -32,7 +32,8 @@ public ResponseEntity> create( @RequestBody @Valid MeetingCreateRequest request ) { MeetingCreateResponse response = meetingService.create(request); - String cookie = cookieManager.createNewCookie(response.token(), response.uuid(), -1); + String path = String.format("/meeting/%s", response.uuid()); + String cookie = cookieManager.createNewCookie(response.token(), path); return ResponseEntity.created(URI.create("/meeting/" + response.uuid())) .header(HttpHeaders.SET_COOKIE, cookie)