Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/auth/src/core/auth/auth_impl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ describe('core/auth/auth_impl', () => {
const token = await auth.getFirebaseAccessToken();
expect(token).to.be.null;
expect(exchangeTokenStub).not.to.have.been.called;
expect(persistenceStub._remove).to.have.been.called;
});

it('should refresh the token if token is expiring in next 1 minute and a token refresh handler is set', async () => {
Expand Down Expand Up @@ -442,6 +443,7 @@ describe('core/auth/auth_impl', () => {
'Token refresh failed:',
sinon.match.instanceOf(Error)
);
expect(persistenceStub._remove).to.have.been.called;
});

it('should return null and log an error if the refreshed token is invalid', async () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/auth/src/core/auth/auth_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
}

if (firebaseAccessToken && this.tokenRefreshHandler) {
// Resets the Firebase Access Token to null i.e. logs out the user.
await this._updateFirebaseToken(null);
try {
// Awaits for the callback method to execute. The callback method
// is responsible for performing the exchangeToken(auth, valid3pIdpToken)
Expand All @@ -282,9 +280,10 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
return this.getFirebaseAccessToken(false);
} catch (error) {
console.error('Token refresh failed:', error);
return null;
}
}
// Signs out the user i.e. sets the firebaseToken to null if firebase token is not valid and refresh token handler is not set/ successful.
await this.signOut();
return null;
}

Expand Down
Loading