Reputation: 335
A user in my application has an activeUserPlan field in their session, which is pulled from the server on signIn.
Here's the flow: User purchases a plan using stripe. User is redirected to stripe checkout page. On success, stripe generates a webhook event and dispatched to my api endpoint.
Here's the issue: In the endpoint, I'm now updating the user plan with the new plan name. But the session on the client now has stale data, since activeUserPlan still has the old value. I can't use unstable_update in the endpoint, as it's not tied to a user request. So user has an upgraded plan in db, but session data is stale after purchasing.
What's the practice I should be using to force a session update after this plan has been purchased? I somehow need to pull the fresh data from the db and update the session.
I could of course sign the user out, which will force a recreation of the session object with fresh db data. But is that the best practice?
Upvotes: 0
Views: 32