diff --git a/frontend/src/stores/useAuthStore.ts b/frontend/src/stores/useAuthStore.ts index 16f6ffc..73fe7c3 100644 --- a/frontend/src/stores/useAuthStore.ts +++ b/frontend/src/stores/useAuthStore.ts @@ -9,6 +9,7 @@ export interface IUserState { currentDomain: IDomainInfo; LeftDrawer: boolean; userId?: string; + permissions: 'admin'|'user'; } export const useAuthStore = defineStore('auth', { @@ -18,6 +19,7 @@ export const useAuthStore = defineStore('auth', { LeftDrawer: false, currentDomain: {} as IDomainInfo, userId: '', + permissions: 'user' }), getters: { toggleLeftDrawer(): boolean { @@ -36,7 +38,9 @@ export const useAuthStore = defineStore('auth', { const result = await api.post(`api/token`, params); console.info(result); this.token = result.data.access_token; - this.userId = jwtDecode(result.data.access_token).sub; + const tokenJson = jwtDecode(result.data.access_token) + this.userId = tokenJson.sub; + this.permissions = (tokenJson as any).permissions ?? 'user'; api.defaults.headers['Authorization'] = 'Bearer ' + this.token; this.currentDomain = await this.getCurrentDomain(); router.push(this.returnUrl || '/');