Skip to content

Commit

Permalink
Remove all cookies with withCredentials set to false
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-szlapa committed Nov 13, 2024
1 parent da7178f commit e000a13
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions packages/auth_demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,12 @@ function App() {
}
}

const clearCognitoCookiesExcept = (accessToken) => {
// Split cookies into an array
const cookies = document.cookie.split("; ")

// Iterate over all cookies
cookies.forEach(cookie => {
const cookieName = cookie.split("=")[0].trim() // Extract the cookie name

// Clear the cookie if it starts with "CognitoIdentityServiceProvider" but does not contain the access token
if (cookieName.startsWith("CognitoIdentityServiceProvider") && !cookie.includes(accessToken)) {
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`
}
})
}

const fetchPrescriptionData = async () => {
if (!prescriptionId) {
setError('Please enter a Prescription ID.')
return
}

// Clear all cookies with 'CognitoIdentityServiceProvider' prefix except those containing the access token
clearCognitoCookiesExcept(accessToken)

setLoading(true)
setPrescriptionData(null)
setError(null)
Expand Down

0 comments on commit e000a13

Please sign in to comment.