From 9f1f0c9b6037ff4f6d830328d6c0d9cb690cd3e5 Mon Sep 17 00:00:00 2001 From: Jerome Villiseck Date: Mon, 4 Nov 2024 15:29:37 +0100 Subject: [PATCH 1/6] =?UTF-8?q?-=20Mise=20en=20place=20du=20bool=C3=A9ean?= =?UTF-8?q?=20pour=20retourner=20le=20role=20dans=20le=20store?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/authStore.js | 11 ++++++----- src/views/Exemplarisation/ExempSteps.vue | 3 ++- src/views/Exemplarisation/ExempTable.vue | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/store/authStore.js b/src/store/authStore.js index 0e685fa..d78d370 100644 --- a/src/store/authStore.js +++ b/src/store/authStore.js @@ -6,11 +6,11 @@ export const useAuthStore = defineStore('auth', { token: sessionStorage.getItem('token'), authenticated: !!sessionStorage.getItem('token'), }), - + getters: { getUser: (state) => state.user, isAuthenticated: (state) => state.authenticated, - getToken: (state) => state.token + getToken: (state) => state.token, }, actions: { login(user, token) { @@ -27,11 +27,12 @@ export const useAuthStore = defineStore('auth', { sessionStorage.setItem('user', JSON.stringify(this.user)) sessionStorage.setItem('token', this.token); }, - setToken(token) { - this.token = token; - }, setUser(user){ this.user = user; + }, + isAdmin() { + console.log(JSON.stringify(this.user)) + return this.user.role === 'ADMIN'; } }, }); diff --git a/src/views/Exemplarisation/ExempSteps.vue b/src/views/Exemplarisation/ExempSteps.vue index fb12d81..858eecc 100644 --- a/src/views/Exemplarisation/ExempSteps.vue +++ b/src/views/Exemplarisation/ExempSteps.vue @@ -108,7 +108,7 @@