Skip to content

Commit

Permalink
fix: send SIGNED_OUT wherever session is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
bombillazo committed Sep 29, 2024
1 parent ef0dd53 commit b852b59
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ export default class GoTrueClient {
if (error) {
this._debug('#_initialize()', 'error detecting session from URL', error)

if (
error?.code === 'identity_already_exists'
) {
if (error?.code === 'identity_already_exists') {
return { error }
}

Expand Down Expand Up @@ -1191,7 +1189,6 @@ export default class GoTrueClient {

await this._removeSession()
await removeItemAsync(this.storage, `${this.storageKey}-code-verifier`)
await this._notifyAllSubscribers('SIGNED_OUT', null)
}

return { data: { user: null }, error }
Expand Down Expand Up @@ -1588,7 +1585,6 @@ export default class GoTrueClient {
if (scope !== 'others') {
await this._removeSession()
await removeItemAsync(this.storage, `${this.storageKey}-code-verifier`)
await this._notifyAllSubscribers('SIGNED_OUT', null)
}
return { error: null }
})
Expand Down Expand Up @@ -1891,7 +1887,6 @@ export default class GoTrueClient {
this._debug(debugName, 'session is not valid')
if (currentSession !== null) {
await this._removeSession()
await this._notifyAllSubscribers('SIGNED_OUT', null)
}

return
Expand Down Expand Up @@ -1919,7 +1914,6 @@ export default class GoTrueClient {
error
)
await this._removeSession()
await this._notifyAllSubscribers('SIGNED_OUT', null)
}
}
}
Expand Down Expand Up @@ -1976,7 +1970,6 @@ export default class GoTrueClient {

if (!isAuthRetryableFetchError(error)) {
await this._removeSession()
await this._notifyAllSubscribers('SIGNED_OUT', null)
}

this.refreshingDeferred?.resolve(result)
Expand Down Expand Up @@ -2044,6 +2037,7 @@ export default class GoTrueClient {
this._debug('#_removeSession()')

await removeItemAsync(this.storage, this.storageKey)
await this._notifyAllSubscribers('SIGNED_OUT', null)
}

/**
Expand Down Expand Up @@ -2087,13 +2081,11 @@ export default class GoTrueClient {
// finished and tests run endlessly. This can be prevented by calling
// `unref()` on the returned object.
ticker.unref()
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error TS has no context of Deno
} else if (typeof Deno !== 'undefined' && typeof Deno.unrefTimer === 'function') {
// similar like for NodeJS, but with the Deno API
// https://deno.land/api@latest?unstable&s=Deno.unrefTimer
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error TS has no context of Deno
Deno.unrefTimer(ticker)
}

Expand Down

0 comments on commit b852b59

Please sign in to comment.