Skip to content

Commit

Permalink
fix: ProductService 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yurim0628 committed Jan 18, 2024
1 parent b4f17d3 commit c60978e
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import jakarta.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -196,26 +193,38 @@ private String generateOrRetrieveAnonymousKey(HttpServletRequest request, HttpSe

if (cookies != null) {
String anonymousKey = Arrays.stream(cookies)
.filter(cookie -> "AnonymousKey".equals(cookie.getName()))
.map(Cookie::getValue)
.findFirst()
.orElse(null);
.filter(cookie -> "AnonymousKey".equals(cookie.getName()))
.map(Cookie::getValue)
.findFirst()
.orElse(null);

if (anonymousKey == null) {
ResponseCookie cookie = ResponseCookie.from("AnonymousKey", UUID.randomUUID().toString())
anonymousKey = UUID.randomUUID().toString();
ResponseCookie cookie = ResponseCookie.from("AnonymousKey", anonymousKey)
.domain(".golden-ticket.site")
.httpOnly(false)
.secure(true)
.path("/")
.sameSite("None")
.build();

response.addHeader("Set-Cookie", cookie.toString());
}

return anonymousKey;
} else {
String anonymousKey = UUID.randomUUID().toString();
ResponseCookie cookie = ResponseCookie.from("AnonymousKey", anonymousKey)
.domain(".golden-ticket.site")
.httpOnly(false)
.secure(true)
.path("/")
.sameSite("None")
.build();

response.addHeader("Set-Cookie", cookie.toString());
}


response.addHeader("Set-Cookie", cookie.toString());

return anonymousKey;
} else {
return null;
}
}

Expand Down

0 comments on commit c60978e

Please sign in to comment.