Skip to content

Commit

Permalink
fix: Call SIGNED_OUT event where session is removed (#854)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?

This adds the SIGNED_OUT event missing in some logic that clears/logs
out the session.

## What is the current behavior?

#853
  • Loading branch information
bombillazo authored Oct 14, 2024
1 parent 4b7455c commit 436fd9f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,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 @@ -1587,7 +1586,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 @@ -1875,7 +1873,7 @@ export default class GoTrueClient {
}

/**
* Recovers the session from LocalStorage and refreshes
* Recovers the session from LocalStorage and refreshes the token
* Note: this method is async to accommodate for AsyncStorage e.g. in React native.
*/
private async _recoverAndRefresh() {
Expand Down Expand Up @@ -1973,7 +1971,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 @@ -2041,6 +2038,7 @@ export default class GoTrueClient {
this._debug('#_removeSession()')

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

/**
Expand Down Expand Up @@ -2084,11 +2082,11 @@ export default class GoTrueClient {
// finished and tests run endlessly. This can be prevented by calling
// `unref()` on the returned object.
ticker.unref()
// @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
// @ts-ignore
// @ts-expect-error TS has no context of Deno
Deno.unrefTimer(ticker)
}

Expand Down

0 comments on commit 436fd9f

Please sign in to comment.