From 3cf5d5f860418c6ffb6206995144b188caa6e6b2 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 19 Sep 2022 11:20:30 +0200 Subject: [PATCH] fix(nc-gui): reset roles on app load --- packages/nc-gui/composables/useGlobal/index.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/nc-gui/composables/useGlobal/index.ts b/packages/nc-gui/composables/useGlobal/index.ts index 49ead004bf..4591ff46a0 100644 --- a/packages/nc-gui/composables/useGlobal/index.ts +++ b/packages/nc-gui/composables/useGlobal/index.ts @@ -62,6 +62,22 @@ export const useGlobal = (): UseGlobalReturn => { { immediate: true }, ) + watch( + state.jwtPayload, + (nextPayload) => { + if (nextPayload) { + state.user.value = { + id: nextPayload.id, + email: nextPayload.email, + firstname: nextPayload.firstname, + lastname: nextPayload.lastname, + roles: nextPayload.roles, + } + } + }, + { immediate: true }, + ) + const globalState = { ...state, ...getters, ...actions } as UseGlobalReturn /** provide a fresh state instance into nuxt app */