Use a pinia store to manage account state
Refactor the existing scattered code dealing with the account state into a pinia store.
This commit is contained in:
parent
fae8b4e2e4
commit
e722876aae
12 changed files with 126 additions and 98 deletions
|
@ -1,14 +1,14 @@
|
|||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
const sessionStore = useSessionStore();
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
if (!sessionStore.account) {
|
||||
if (!accountStore.valid) {
|
||||
console.log("Not logged in, redirecting to /login");
|
||||
return navigateTo("/login");
|
||||
}
|
||||
|
||||
if (
|
||||
to.meta.allowedAccountTypes
|
||||
&& !to.meta.allowedAccountTypes.includes(sessionStore.account.type)
|
||||
&& !to.meta.allowedAccountTypes.includes(accountStore.type!)
|
||||
) {
|
||||
throw createError({
|
||||
status: 403,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue