Skip to content

Commit 69e9995

Browse files
committed
Remove firebaseToken from persistence if tokenRefreshHandler is not set and token is expired
1 parent 7e14a59 commit 69e9995

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/auth/src/core/auth/auth_impl.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ describe('core/auth/auth_impl', () => {
367367
const token = await auth.getFirebaseAccessToken();
368368
expect(token).to.be.null;
369369
expect(exchangeTokenStub).not.to.have.been.called;
370+
expect(persistenceStub._remove).to.have.been.calledWith(
371+
'firebase:persistence-token:api-key:test-app'
372+
);
370373
});
371374

372375
it('should refresh the token if token is expiring in next 1 minute and a token refresh handler is set', async () => {
@@ -442,6 +445,9 @@ describe('core/auth/auth_impl', () => {
442445
'Token refresh failed:',
443446
sinon.match.instanceOf(Error)
444447
);
448+
expect(persistenceStub._remove).to.have.been.calledWith(
449+
'firebase:persistence-token:api-key:test-app'
450+
);
445451
});
446452

447453
it('should return null and log an error if the refreshed token is invalid', async () => {

packages/auth/src/core/auth/auth_impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
266266
return firebaseAccessToken.token;
267267
}
268268

269+
// Resets the Firebase Access Token to null i.e. logs out the user.
270+
await this._updateFirebaseToken(null);
269271
if (firebaseAccessToken && this.tokenRefreshHandler) {
270-
// Resets the Firebase Access Token to null i.e. logs out the user.
271-
await this._updateFirebaseToken(null);
272272
try {
273273
// Awaits for the callback method to execute. The callback method
274274
// is responsible for performing the exchangeToken(auth, valid3pIdpToken)

0 commit comments

Comments
 (0)