Skip to content

Commit 55cfea3

Browse files
committed
Implement signOut for R-GCIP
1 parent 5616d78 commit 55cfea3

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

packages/auth/demo/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@ function onRefreshToken() {
13051305
function onSignOut() {
13061306
setLastUser(auth.currentUser);
13071307
auth.signOut().then(signOut, onAuthError);
1308+
regionalAuth.signOut();
13081309
}
13091310

13101311
/**

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ describe('core/auth/auth_impl', () => {
308308
expect(persistenceStub._remove).to.have.been.called;
309309
expect(auth.currentUser).to.be.null;
310310
});
311+
it('sets currentUser to null, calls remove', async () => {
312+
const token: FirebaseToken = {
313+
token: 'test-token',
314+
expirationTime: 123456789
315+
};
316+
await auth._updateFirebaseToken(token);
317+
await auth.signOut();
318+
expect(persistenceStub._remove).to.have.been.called;
319+
expect(auth.firebaseToken).to.be.null;
320+
});
311321
it('is blocked if a beforeAuthStateChanged callback throws', async () => {
312322
await auth._updateCurrentUser(testUser(auth, 'test'));
313323
auth.beforeAuthStateChanged(sinon.stub().throws());

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
490490
await this._setRedirectUser(null);
491491
}
492492

493+
// Clear Firebase token for Regional Auth Instance when signOut is called
494+
await this._updateFirebaseToken(null);
493495
// Prevent callbacks from being called again in _updateCurrentUser, as
494496
// they were already called in the first line.
495497
return this._updateCurrentUser(null, /* skipBeforeStateCallbacks */ true);

0 commit comments

Comments
 (0)