Skip to content

[Auth] Add missing initializer for providerData to UserImpl #5938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2022
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
5 changes: 5 additions & 0 deletions .changeset/curvy-brooms-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/auth": patch
---

Fix bug where `user.providerData` field was being improperly initialized
16 changes: 16 additions & 0 deletions packages/auth/src/core/user/user_impl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ describe('core/user/user_impl', () => {
photoURL: 'photo',
emailVerified: false,
isAnonymous: true,
providerData: [{
providerId: 'password',
displayName: null,
photoURL: null,
email: '[email protected]',
phoneNumber: null,
uid: 'i-am-uid'
}],
tenantId: 'tenant-id'
});

Expand All @@ -274,6 +282,14 @@ describe('core/user/user_impl', () => {
expect(copy.toJSON()).to.eql(user.toJSON());
expect(copy.auth).to.eq(newAuth);
expect(copy.tenantId).to.eq('tenant-id');
expect(copy.providerData).to.eql([{
providerId: 'password',
displayName: null,
photoURL: null,
email: '[email protected]',
phoneNumber: null,
uid: 'i-am-uid'
}]);
});
});
});
9 changes: 5 additions & 4 deletions packages/auth/src/core/user/user_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export class UserImpl implements UserInternal {

uid: string;
auth: AuthInternal;
emailVerified = false;
isAnonymous = false;
tenantId: string | null = null;
emailVerified: boolean;
isAnonymous: boolean;
tenantId: string | null;
readonly metadata: UserMetadata;
providerData: MutableUserInfo[] = [];
providerData: MutableUserInfo[];

// Optional fields from UserInfo
displayName: string | null;
Expand All @@ -88,6 +88,7 @@ export class UserImpl implements UserInternal {
this.photoURL = opt.photoURL || null;
this.isAnonymous = opt.isAnonymous || false;
this.tenantId = opt.tenantId || null;
this.providerData = opt.providerData ? [...opt.providerData] : [];
this.metadata = new UserMetadata(
opt.createdAt || undefined,
opt.lastLoginAt || undefined
Expand Down
1 change: 1 addition & 0 deletions packages/auth/src/model/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface UserParameters {
isAnonymous?: boolean | null;
emailVerified?: boolean | null;
tenantId?: string | null;
providerData?: MutableUserInfo[] | null;

createdAt?: string | null;
lastLoginAt?: string | null;
Expand Down