How to logout app and clear data? #16834
-
Building a complex app with pinia stores. When user logs out, I'd like to clear all data and show the login page again. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
How are you storing the user data? in the function you logout the user, you need to clear all data related to that. If you could share parts of your code, we could give more explanation. |
Beta Was this translation helpful? Give feedback.
-
I have 11 pinia stores holding lots of user data which should all be purged from memory. If I just logout the user from firebase and use router to go back to the login page, the next person to log in gets all the same data. |
Beta Was this translation helpful? Give feedback.
-
ah, ok, so you are using Firebase. I've a project using firebase as well, I'm only using email login, but I think this is an idea. I'm using compostion API and script setup:
|
Beta Was this translation helpful? Give feedback.
-
OK thanks for the suggestion. |
Beta Was this translation helpful? Give feedback.
-
You can manipulate the whole state of a store, or even the whole application(all of the stores): As an alternative solution, you can go the obvious but maybe not-so-scalable way. You can implement a |
Beta Was this translation helpful? Give feedback.
-
This works great:
|
Beta Was this translation helpful? Give feedback.
Great. Thanks for the suggestions.