Skip to content

Commit af92348

Browse files
authored
[Auth] Add missing initializer for providerData to UserImpl (#5938)
* Add missing initializer for providerData to UserImpl * Changeset
1 parent d612d6f commit af92348

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

.changeset/curvy-brooms-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/auth": patch
3+
---
4+
5+
Fix bug where `user.providerData` field was being improperly initialized

packages/auth/src/core/user/user_impl.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ describe('core/user/user_impl', () => {
264264
photoURL: 'photo',
265265
emailVerified: false,
266266
isAnonymous: true,
267+
providerData: [{
268+
providerId: 'password',
269+
displayName: null,
270+
photoURL: null,
271+
272+
phoneNumber: null,
273+
uid: 'i-am-uid'
274+
}],
267275
tenantId: 'tenant-id'
268276
});
269277

@@ -274,6 +282,14 @@ describe('core/user/user_impl', () => {
274282
expect(copy.toJSON()).to.eql(user.toJSON());
275283
expect(copy.auth).to.eq(newAuth);
276284
expect(copy.tenantId).to.eq('tenant-id');
285+
expect(copy.providerData).to.eql([{
286+
providerId: 'password',
287+
displayName: null,
288+
photoURL: null,
289+
290+
phoneNumber: null,
291+
uid: 'i-am-uid'
292+
}]);
277293
});
278294
});
279295
});

packages/auth/src/core/user/user_impl.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ export class UserImpl implements UserInternal {
6161

6262
uid: string;
6363
auth: AuthInternal;
64-
emailVerified = false;
65-
isAnonymous = false;
66-
tenantId: string | null = null;
64+
emailVerified: boolean;
65+
isAnonymous: boolean;
66+
tenantId: string | null;
6767
readonly metadata: UserMetadata;
68-
providerData: MutableUserInfo[] = [];
68+
providerData: MutableUserInfo[];
6969

7070
// Optional fields from UserInfo
7171
displayName: string | null;
@@ -88,6 +88,7 @@ export class UserImpl implements UserInternal {
8888
this.photoURL = opt.photoURL || null;
8989
this.isAnonymous = opt.isAnonymous || false;
9090
this.tenantId = opt.tenantId || null;
91+
this.providerData = opt.providerData ? [...opt.providerData] : [];
9192
this.metadata = new UserMetadata(
9293
opt.createdAt || undefined,
9394
opt.lastLoginAt || undefined

packages/auth/src/model/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface UserParameters {
4242
isAnonymous?: boolean | null;
4343
emailVerified?: boolean | null;
4444
tenantId?: string | null;
45+
providerData?: MutableUserInfo[] | null;
4546

4647
createdAt?: string | null;
4748
lastLoginAt?: string | null;

0 commit comments

Comments
 (0)