Skip to content

Commit

Permalink
feat: call SIGNED_OUT event if token refresh fails (#815)
Browse files Browse the repository at this point in the history
If token refresh fails, such as when the user has logged out from other
places, or their session has been terminated, the `SIGNED_OUT` event
should be fired and the session should be removed from storage.
  • Loading branch information
hf authored Dec 3, 2023
1 parent e46a324 commit a0ff059
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,11 @@ export default class GoTrueClient {
if (isAuthError(error)) {
const result = { session: null, error }

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

this.refreshingDeferred?.resolve(result)

return result
Expand Down

0 comments on commit a0ff059

Please sign in to comment.