Skip to content

Commit 73d7c54

Browse files
authored
fix: stores not initializing when refreshing the page while logged in (#107)
1 parent 7d2b278 commit 73d7c54

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ router.beforeEach(async (to) => {
232232

233233
// Automatically login using mock when in development mode
234234
if (import.meta.env.VITE_NODE_ENV === 'development' && !authenticated) {
235+
console.info('Backoffice is in development mode: mocking auth...');
235236
await authStore.MockLogin({
236237
id: 'dev',
237238
name: 'dev',
238239
roles: [SecurityGroup.ADMIN],
239240
});
240-
await authStore.initStores();
241241
}
242242

243243
// Check if user still has valid cookies - ignore if specific request to /auth

src/stores/auth.store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export const useAuthStore = defineStore('auth', {
6868
this.roles = user.data.roles;
6969
this.securityGroups = securityGroups.data;
7070
this.authenticating = false;
71+
72+
await this.initStores();
7173
return true;
7274
},
7375
/**
@@ -116,6 +118,8 @@ export const useAuthStore = defineStore('auth', {
116118
this.name = user.data.name;
117119
this.roles = user.data.roles;
118120
this.securityGroups = securityGroups.data;
121+
122+
await this.initStores();
119123
return true;
120124
},
121125
/**

0 commit comments

Comments
 (0)