How to reset Nuxt application's state on logout?
P粉706038741
P粉706038741 2023-09-16 20:59:12
0
1
621

When the user exits the application, Pinia's persistent authStore state is reset and the user is redirected to /login. However, if the next user logs in without refreshing the page, the main page still displays the previous user's data because it is still in the page's state. How should I solve this problem?

How should I reset every state in the application on logout? Are there any recommended solutions for isolating the state of one authentication session from another?

I've tried manually resetting the page's state when the "logout" button is pressed on the page, in case it doesn't refresh later, but that only helps me with part of the problem: most of the time, the button and it's handler are located In a separate page within the layout or settings.

P粉706038741
P粉706038741

reply all(1)
P粉752812853

The solution I found was to trigger a full reload of the app after logout, calling reloadNuxtApp. This will solve the problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template