From e456d00a7d054b2e95476562a087f2b12301e800 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 5 Oct 2021 11:35:37 -0700 Subject: [PATCH] [Auth] Fix tenantId field when setting user via updateCurrentUser (#5577) * Fix tenantId field when setting user via updateCurrentUser * Add changeset --- .changeset/twelve-scissors-wink.md | 5 +++++ packages/auth/src/core/user/user_impl.test.ts | 4 +++- packages/auth/src/core/user/user_impl.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/twelve-scissors-wink.md diff --git a/.changeset/twelve-scissors-wink.md b/.changeset/twelve-scissors-wink.md new file mode 100644 index 00000000000..3c0013b105e --- /dev/null +++ b/.changeset/twelve-scissors-wink.md @@ -0,0 +1,5 @@ +--- +"@firebase/auth": patch +--- + +Fix bug where `user.tenantId` wasn't being carried over in `updateCurrentUser` function diff --git a/packages/auth/src/core/user/user_impl.test.ts b/packages/auth/src/core/user/user_impl.test.ts index 8b96f4dc31c..375f83d17d5 100644 --- a/packages/auth/src/core/user/user_impl.test.ts +++ b/packages/auth/src/core/user/user_impl.test.ts @@ -263,7 +263,8 @@ describe('core/user/user_impl', () => { phoneNumber: 'number', photoURL: 'photo', emailVerified: false, - isAnonymous: true + isAnonymous: true, + tenantId: 'tenant-id' }); const newAuth = await testAuth(); @@ -272,6 +273,7 @@ describe('core/user/user_impl', () => { expect(copy.stsTokenManager).not.to.eq(user.stsTokenManager); expect(copy.toJSON()).to.eql(user.toJSON()); expect(copy.auth).to.eq(newAuth); + expect(copy.tenantId).to.eq('tenant-id'); }); }); }); diff --git a/packages/auth/src/core/user/user_impl.ts b/packages/auth/src/core/user/user_impl.ts index 7e2760e36d7..2d7ab45710a 100644 --- a/packages/auth/src/core/user/user_impl.ts +++ b/packages/auth/src/core/user/user_impl.ts @@ -87,6 +87,7 @@ export class UserImpl implements UserInternal { this.phoneNumber = opt.phoneNumber || null; this.photoURL = opt.photoURL || null; this.isAnonymous = opt.isAnonymous || false; + this.tenantId = opt.tenantId || null; this.metadata = new UserMetadata( opt.createdAt || undefined, opt.lastLoginAt || undefined