T
TanStack11mo ago
ambitious-aqua

Invalidating router+query auth for logout

Hi, I'm trying to implement logout and I'm noticing some odd behaviour when invalidating the router. The beforeLoad handler for the root seems to have updated while beforeLoad for /dashboard has not browser console logs after logout
__root beforeLoad userId: null
dashboard beforeLoad userId: 123
__root beforeLoad userId: null
dashboard beforeLoad userId: 123
seems like it's not being merged properly. I've created a min repro here: https://github.com/alakhpc/tss-test
5 Replies
ambitious-aqua
ambitious-aquaOP11mo ago
you can see the console log when signing out here: https://tss-test.pages.dev I would expect the userId to be null and redirect the user to the login page
flat-fuchsia
flat-fuchsia11mo ago
Hey @jepcd, that's because you're receiving the dashboard's context when beforeLoad re-runs https://discord.com/channels/719702312431386674/1300114602251649096
flat-fuchsia
flat-fuchsia11mo ago
That's how I solved this
No description
flat-fuchsia
flat-fuchsia11mo ago
I don't really update the "session" context prop, just update it's type
ambitious-aqua
ambitious-aquaOP10mo ago
ah that definitely fixed it. Thanks!

Did you find this page helpful?