Home  >  Q&A  >  body text

How to reset Nuxt application's state on logout?

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粉706038741P粉706038741398 days ago593

reply all(1)I'll reply

  • P粉752812853

    P粉7528128532023-09-17 20:02:32

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

    reply
    0
  • Cancelreply