Skip to content

user.data not updated when changing deactivated to false and setting data (formerly: observe current user not working when evaluation expired or deactivated) #2158

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

Open
retotito opened this issue Apr 22, 2025 · 3 comments
Labels

Comments

@retotito
Copy link

Hy
I'm observing the currentUser, to be able to notify the user inside the app, if a users evaluation or subscription expires or a subscription started.

const userObservable = dexieJS.db.cloud.currentUser

In cases of subscription expire or starting, i use the dexieCloudRestAPI to set the "type" and so on.

This works great as long as
"type" is "prod", "valid until" is a date in the future and "deactivated" is "false" or "undefined.
or
"type" is "eval", "valid until" is a date in the future and "deactivated" is "false" or "undefined.

But when "valid until" is in the past or "deactivated" is "true"(or a date),
from then on the observer is not working anymore, because there is a HttpError: 403 with the dexieCloudAddon.

When the "type" is set back to "prod" via dexieCloudRestAPI, because the user purchased a subscription on Stripe or somewhere else,
then the app has to be restarted to connect to the cloud again.
Sometimes you also have to restart twice, to reconnect.

Is there any solution in Dexie for that usecase?
Or is my concept totally wrong?

Thanks for some answers.

@dfahlander
Copy link
Collaborator

Yes, we are aware of this and it is according to how we have specified it: If a user has expired, it will stop connecting to the cloud unless db.cloud.sync() called explicitly by the application code.

It is recommended that the app should actively call db.cloud.sync() to refresh the license, for example as a step after a purchase flow, or allow the user to click a refresh button in the app's profile settings page where license status is visible.

@retotito
Copy link
Author

Thanks, good to know.
There is just a thing.
When i set deactivated to true via restAPI:
{ "userId": user, "type": "eval", "deactivated": true, "data": { "RC_event": RC_event,// a nested object "test_string": "test set to deactivated", // a string } }

And then set it back to deactivated false:
{ "userId": user, "type": "prod", "deactivated": false, "validUntil": "2099-04-01T19:18:44+02:00", "evalDaysLeft": 0, "data": { "RC_event": RC_event, // a nested object "test_string": "test set to production", // a string } }

And then use db.cloud.sync() or restart the app, the "data" i did add to the User does not sync down to the app.

This only happens, when sync was deactivated.
When i now, while it's not deactivated, update the "data" again, it does sync.

@dfahlander
Copy link
Collaborator

Thanks! I mark this as a bug and add it to the backlog. Were you able to work around it?

@dfahlander dfahlander added the bug label Apr 30, 2025
@dfahlander dfahlander changed the title observe current user not working when evaluation expired or deactivated user.data not updated when changing deactivated to false and setting data (formerly observe current user not working when evaluation expired or deactivated) Apr 30, 2025
@dfahlander dfahlander changed the title user.data not updated when changing deactivated to false and setting data (formerly observe current user not working when evaluation expired or deactivated) user.data not updated when changing deactivated to false and setting data (formerly: observe current user not working when evaluation expired or deactivated) Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

2 participants