Skip to content

Commit

Permalink
Merge pull request #126 from Yanol-Market/feature/83
Browse files Browse the repository at this point in the history
generateOrRetrieveAnonymousKey 수정
  • Loading branch information
yurim0628 authored Jan 18, 2024
2 parents 3fdba18 + ecd2527 commit 8b6f17d
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,29 +191,31 @@ private String buildReservationUrl(String endpoint, Long pathVariable) {
}

private String generateOrRetrieveAnonymousKey(HttpServletRequest request, HttpServletResponse response) {
String anonymousKey = Arrays.stream(request.getCookies())
.filter(
cookie -> "AnonymousKey".equals(cookie.getName())
)
.map(
cookie -> cookie.getValue()
)
Cookie[] cookies = request.getCookies();

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

if (anonymousKey == null) {
ResponseCookie cookie = ResponseCookie.from("AnonymousKey", UUID.randomUUID().toString())
if (anonymousKey == null) {
ResponseCookie cookie = ResponseCookie.from("AnonymousKey", UUID.randomUUID().toString())
.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;
}

return anonymousKey;
}

private void updateProductViewCount(String userKey, String productKey) {
Expand Down

0 comments on commit 8b6f17d

Please sign in to comment.