Skip to content

Commit

Permalink
- Mise en place du booléean pour retourner le role dans le store
Browse files Browse the repository at this point in the history
  • Loading branch information
jvk88511334 committed Nov 4, 2024
1 parent 0d69440 commit 9f1f0c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/store/authStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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';
}
},
});
3 changes: 2 additions & 1 deletion src/views/Exemplarisation/ExempSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

<script setup>
import { onMounted, ref } from 'vue';
import {onMounted, ref} from 'vue'
import itemService from '@/service/ItemService';
import router from '@/router';
import SelectFile from '@/components/SelectFile.vue';
Expand All @@ -118,6 +118,7 @@ import Simulation from "@/components/Simulation.vue";
import DialogLancerTraitement from '@/components/Dialog/DialogLancerTraitement.vue';
import DialogSuppression from '@/components/Dialog/DialogSuppression.vue';
import RecapDemande from '@/components/RecapDemande.vue';
import {useAuthStore} from '@/store/authStore'
const emits = defineEmits(['backendError', 'backendSuccess', 'login-success'])
const props = defineProps({id : {type: String}});
Expand Down
3 changes: 3 additions & 0 deletions src/views/Exemplarisation/ExempTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import DialogCommentaire from '@/components/Dialog/DialogCommentaire.vue';
import itemService from '@/service/ItemService';
import MenuDownloadFile from '@/components/MenuDownloadFile.vue';
import moment from 'moment';
import {useAuthStore} from '@/store/authStore'
//Emit
const emit = defineEmits(['backendError', 'backendSuccess']);
Expand Down Expand Up @@ -259,6 +260,8 @@ const isDialogOpen = computed(() => {
//Actives or archives demands displayed
const isActiveDemandesDisplayed = ref(false);
const isAdmin = useAuthStore().isAdmin();
//Data initialisation
onMounted(() => {
loadItems('EXEMP', isActiveDemandesDisplayed.value);
Expand Down

0 comments on commit 9f1f0c9

Please sign in to comment.