Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4110

How do I deal with syncing the client session after a server-side webhook event handling? (Auth.js / NextAuth)

$
0
0

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?


Viewing all articles
Browse latest Browse all 4110

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>