File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export default class SupabaseClient {
36
36
protected realtime : RealtimeClient
37
37
protected multiTab : boolean
38
38
protected fetch ?: Fetch
39
+ protected changedAccessToken : string | undefined
39
40
40
41
/**
41
42
* Create a new client for use in the browser.
@@ -266,19 +267,21 @@ export default class SupabaseClient {
266
267
token : string | undefined ,
267
268
source : 'CLIENT' | 'STORAGE'
268
269
) {
269
- if ( token == this . auth . session ( ) ?. access_token ) {
270
- // Token is unchanged
271
- return null
272
- } else if ( event === 'SIGNED_OUT' || event === 'USER_DELETED' ) {
273
- // Token is removed
274
- this . removeAllSubscriptions ( )
275
- if ( source == 'STORAGE' ) this . auth . signOut ( )
276
- } else if ( event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN' ) {
270
+ if (
271
+ ( event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN' ) &&
272
+ this . changedAccessToken !== token
273
+ ) {
277
274
// Token has changed
278
275
this . realtime . setAuth ( token ! )
279
276
// Ideally we should call this.auth.recoverSession() - need to make public
280
277
// to trigger a "SIGNED_IN" event on this client.
281
278
if ( source == 'STORAGE' ) this . auth . setAuth ( token ! )
279
+
280
+ this . changedAccessToken = token
281
+ } else if ( event === 'SIGNED_OUT' || event === 'USER_DELETED' ) {
282
+ // Token is removed
283
+ this . removeAllSubscriptions ( )
284
+ if ( source == 'STORAGE' ) this . auth . signOut ( )
282
285
}
283
286
}
284
287
}
You can’t perform that action at this time.
0 commit comments