Skip to content

Commit e0b677e

Browse files
mdedysprameshj
andauthoredMar 7, 2023
Explicitly set createdAt and lastLoginAt when cloning UserImpl (#7066)
* Explicilty set createdAt and lastLoginAt when cloning UserImpl * Use metadata._copy instead of manually setting metadata * Fix test case for user_imply _clone function * Create fluffy-seas-behave.md --------- Co-authored-by: prameshj <[email protected]>
1 parent 5099f0f commit e0b677e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed
 

‎.changeset/fluffy-seas-behave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/auth": patch
3+
---
4+
5+
Explicitly set createdAt and lastLoginAt when cloning UserImpl

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ describe('core/user/user_impl', () => {
274274
uid: 'i-am-uid'
275275
}
276276
],
277-
tenantId: 'tenant-id'
277+
tenantId: 'tenant-id',
278+
createdAt: '2018-01-01 13:02:56.12345678',
279+
lastLoginAt: '2018-01-05 13:02:56.12345678'
278280
});
279281

280282
const newAuth = await testAuth();
@@ -294,6 +296,7 @@ describe('core/user/user_impl', () => {
294296
uid: 'i-am-uid'
295297
}
296298
]);
299+
expect(copy.metadata.toJSON()).to.eql(user.metadata.toJSON());
297300
});
298301
});
299302
});

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ export class UserImpl implements UserInternal {
140140
}
141141

142142
_clone(auth: AuthInternal): UserInternal {
143-
return new UserImpl({
143+
const newUser = new UserImpl({
144144
...this,
145145
auth,
146146
stsTokenManager: this.stsTokenManager._clone()
147147
});
148+
newUser.metadata._copy(this.metadata);
149+
return newUser;
148150
}
149151

150152
_onReload(callback: NextFn<APIUserInfo>): void {

0 commit comments

Comments
 (0)