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

switch_user should happen after get_profile during log_in_with_credentials #7889

Closed
sync-by-unito bot opened this issue Jul 16, 2024 · 1 comment · Fixed by #7894
Closed

switch_user should happen after get_profile during log_in_with_credentials #7889

sync-by-unito bot opened this issue Jul 16, 2024 · 1 comment · Fixed by #7894
Assignees

Comments

@sync-by-unito
Copy link

sync-by-unito bot commented Jul 16, 2024

Related to HELP-61640 

In Realm React (and likely other SDKs) there's odd behavior with the app change notifier and JWT profile fields, namely that the change notifier fires before the profile is filled, meaning when we re-render the UI based on this change, the user profile that is exposed to the client can still have an empty, unfilled profile.

This is because emit_change_to_subscribers() happens inside switch_user and when logging in, switch_user[ is called before|https://github.com/realm/realm-core/blob/6bebc40a03ca4144050bc672a6cd86c2286caa32/src/realm/object-store/sync/app.cpp#L822] get_profile  and consequently the change notification gets emitted before the profile is retrieved (and does not get re-emitted later). This leads to i.e. a discrepancy between the callback  of the login and app change listener and causes the bad behavior the help ticket is about.

The solution is to to move the call to switch_user into a lambda passed to get_profile and call the completion function afterwards, ensuring the correct order of operations.

Copy link
Author

sync-by-unito bot commented Jul 16, 2024

➤ PM Bot commented:

Jira ticket: RCORE-2200

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2024
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 a pull request may close this issue.

1 participant