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

Reset sync session after user custom data update #5875

Open
rossicler-hostalky opened this issue Jun 8, 2023 · 4 comments
Open

Reset sync session after user custom data update #5875

rossicler-hostalky opened this issue Jun 8, 2023 · 4 comments

Comments

@rossicler-hostalky
Copy link

rossicler-hostalky commented Jun 8, 2023

Problem

When you update a user custom data field that affects a user role permission(s), it doesn't take effect in their permission until realm sync is closed and started again, even if user.refreshCustomData is called.

Solution

One possible solution is to automatically restart the sync session if a user custom data field used in a role permission is updated.

Alternatives

If the solution above is not possible, add a method like "realm.syncSession.restart()" that will preserve all subscriptions to that synced session, but will close and start the session. I know that calling "pause" and "resume" will achieve the same thing, but "resume" doesn't give the idea of starting a new sync session, so it might confuse people (as it did with me).

Sorry if any of my understanding of this is wrong, please correct me if it's the case.

How important is this improvement for you?

I would like to have it but have a workaround

Feature would mainly be used with

Atlas Device Sync

@kneth
Copy link
Contributor

kneth commented Jul 14, 2023

@rossicler-hostalky Thank you for your suggestion/feature request. Restarting the sync session is a bit of an expensive operation. A better solution might be that the ADS server to signal to the client that the permissions have the custom user data should be refreshed - and bubble it through to the app.

@rossicler-hostalky
Copy link
Author

rossicler-hostalky commented Aug 16, 2023

@kneth That makes a lot more sense, having that would be great. Right now I have to use the "workaround" of pausing and resuming the sync session, so having the permissions automatically updated without needing to restart the sync session would be a huge improvement.

@ampopdev
Copy link

ampopdev commented Aug 22, 2023

@kneth @rossicler-hostalky We have exactly same scenario, currently calling pause/resume as workaround as well after updating custom user data that a role depends on, possible duplicate of this issue. But there is a really critical scenario when a new user logs in, then pause/resume does not help. If we restart app then sync works correctly for this new user when updating custom user data, added this other issue.

Tried calling switchUser as well, does not help:

const newUser = await app.logIn(credentials);
app.switchUser(newUser);

But we noticed that we still have 2 users on app.allUsers array.

Is there any known workaround to restart the sync session when new user logs in?

@muhammadasadullahtariq
Copy link

@kneth @rossicler-hostalky We have exactly same scenario, currently calling pause/resume as workaround as well after updating custom user data that a role depends on, possible duplicate of this issue. But there is a really critical scenario when a new user logs in, then pause/resume does not help. If we restart app then sync works correctly for this new user when updating custom user data, added this other issue.

Tried calling switchUser as well, does not help:

const newUser = await app.logIn(credentials);
app.switchUser(newUser);

But we noticed that we still have 2 users on app.allUsers array.

Is there any known workaround to restart the sync session when new user logs in?

@ampopdev did you find any solution i am facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants