Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/com/iemr/common/utils/CookieUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public void addJwtTokenToCookie(String Jwttoken, HttpServletResponse response, H
// Set the SameSite attribute for cross-site request handling (if needed)
String sameSite = "None"; // Allow cross-site cookies (can be 'Strict', 'Lax', or 'None')
cookie.setSecure(true);
// Add the cookie to the response
response.addCookie(cookie);

// Build the Set-Cookie header manually (to add SameSite attribute support)
StringBuilder cookieHeader = new StringBuilder();
Expand All @@ -61,6 +59,9 @@ public void addJwtTokenToCookie(String Jwttoken, HttpServletResponse response, H
}

public String getJwtTokenFromCookie(HttpServletRequest request) {
if (request.getCookies() == null) {
return null; // If cookies are null, return null safely.
}
return Arrays.stream(request.getCookies()).filter(cookie -> "Jwttoken".equals(cookie.getName()))
.map(Cookie::getValue).findFirst().orElse(null);
}
Expand Down
Loading