Skip to content
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

Explicitly set createdAt and lastLoginAt when cloning UserImpl #7066

Merged
merged 4 commits into from Mar 7, 2023

Conversation

mdedys
Copy link
Contributor

@mdedys mdedys commented Feb 28, 2023

Discussion

Problem being addressed:

When calling updateCurrentUser the code clones the UserImpl class but incorrectly clones the UserMetadata resulting in undefined values.

Line of code calling _clone:

return this._updateCurrentUser(user && user._clone(this));

_clone function: https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/core/user/user_impl.ts#L142.

The spread operator only passes keys on the UserImpl class and will not pass the Metadata properties belonging to UserMetadata. This causes https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/core/user/user_impl.ts#L142 to fail.

This is missed in the test because the metadata properties are never set:

@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2023

🦋 Changeset detected

Latest commit: 9fdbdc6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/auth Patch
@firebase/auth-compat Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mdedys mdedys changed the title Explicilty set createdAt and lastLoginAt when cloning UserImpl Explicitly set createdAt and lastLoginAt when cloning UserImpl Feb 28, 2023
@prameshj
Copy link
Contributor

prameshj commented Mar 1, 2023

cc @sam-gc

@prameshj prameshj merged commit e0b677e into firebase:master Mar 7, 2023
@google-oss-bot google-oss-bot mentioned this pull request Mar 14, 2023
renkelvin pushed a commit that referenced this pull request Mar 21, 2023
* 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 <pavithrar@google.com>
renkelvin pushed a commit that referenced this pull request Mar 21, 2023
* 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 <pavithrar@google.com>
@firebase firebase locked and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants