mirror of
https://github.com/sasjs/adapter.git
synced 2026-04-19 04:03:13 +00:00
fix: clear all cookies on session expiry and throw LoginRequiredError
This commit is contained in:
@@ -84,7 +84,16 @@ export class RequestClient implements HttpClient {
|
||||
this.clearLocalStorageTokens()
|
||||
}
|
||||
if (typeof document !== 'undefined') {
|
||||
document.cookie = 'XSRF-TOKEN=; Max-Age=0; Path=/;'
|
||||
this.clearAllCookies()
|
||||
}
|
||||
}
|
||||
|
||||
private clearAllCookies() {
|
||||
const cookies = document.cookie.split(';')
|
||||
for (const cookie of cookies) {
|
||||
const name = cookie.split('=')[0].trim()
|
||||
if (!name) continue
|
||||
document.cookie = `${name}=; Max-Age=0; Path=/;`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,6 +720,10 @@ ${resHeaders}${parsedResBody ? `\n\n${parsedResBody}` : ''}
|
||||
this.isRecoveringFromNetworkError = true
|
||||
try {
|
||||
return await callback()
|
||||
} catch {
|
||||
// Retry also failed — session is dead, surface LoginRequiredError
|
||||
// so the app can prompt re-authentication.
|
||||
throw new LoginRequiredError()
|
||||
} finally {
|
||||
this.isRecoveringFromNetworkError = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user