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

RCORE-2200: Fix switch_user and get_profile during log_in_with_credentials #7894

Merged
merged 13 commits into from
Jul 24, 2024

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Jul 17, 2024

What, How & Why?

Fixes #7889

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed
  • bindgen/spec.yml, if public C++ API changed

@cla-bot cla-bot bot added the cla: yes label Jul 17, 2024
@gagik gagik changed the title Fix switch_user and get_profile during log_in_with_credentials RCORE-2200: Fix switch_user and get_profile during log_in_with_credentials Jul 17, 2024
Copy link

coveralls-official bot commented Jul 18, 2024

Pull Request Test Coverage Report for Build github_pull_request_299776

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 2 files are covered.
  • 92 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.02%) to 91.01%

Files with Coverage Reduction New Missed Lines %
src/realm/sync/network/websocket.cpp 1 71.79%
test/test_index_string.cpp 1 93.48%
src/realm/cluster.cpp 2 75.85%
src/realm/query_expression.cpp 2 86.62%
src/realm/table.cpp 4 90.42%
test/object-store/util/sync/baas_admin_api.cpp 5 84.03%
src/realm/bplustree.cpp 6 72.55%
src/realm/sync/noinst/client_impl_base.cpp 6 81.97%
src/realm/sync/network/network.hpp 7 85.28%
src/realm/sync/instruction_applier.cpp 10 68.01%
Totals Coverage Status
Change from base Build 2512: -0.02%
Covered Lines: 216401
Relevant Lines: 237777

💛 - Coveralls

@gagik gagik requested a review from tgoyne July 18, 2024 10:56
switch_user(user);
get_profile(user, std::move(completion));

get_profile(user, [this, completion = std::move(completion)](const std::shared_ptr<User>& user,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't worked with C++ in a little while, tried to get it to be equivalent but let me know if this move, etc. doesn't make sense

Copy link
Member

@kraenhansen kraenhansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks about right to me.


get_profile(user, [this, completion = std::move(completion)](const std::shared_ptr<User>& user,
Optional<AppError> error) {
switch_user(user);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably only want to switch users if the profile fetch succeeded?

Copy link
Contributor Author

@gagik gagik Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that be a better experience? We'd potentially be breaking more functionality which isn't necessarily dependent on the user's profile itself (i.e. giving the client the new user on completition callback but it having no profile and an error to handle seems nicer than not giving the client the new user at all or giving it on the completition callback with the error but not actually switching the user)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the initial profile fetch fails then the user effectively isn't logged in yet and isn't really in a usable state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgoyne made the change, let me know if more is needed

@gagik gagik requested a review from tgoyne July 24, 2024 07:16
@gagik gagik merged commit 3339bbb into master Jul 24, 2024
40 checks passed
@gagik gagik deleted the gagik/fix-profile-notification-order branch July 24, 2024 19:32
@github-actions github-actions bot mentioned this pull request Jul 25, 2024
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

switch_user should happen after get_profile during log_in_with_credentials
3 participants