feat : ajout du rôle ROLE_BUREAU et hiérarchie de rôles
- Hiérarchie Symfony : ROLE_ADMIN -> ROLE_BUREAU -> ROLE_USER - ROLE_BUREAU autorise : export inventaire bovin, sync EDNOTIF, visibilité des colonnes Prix/kg et Prix total - Front : utility roles.ts qui réplique la hiérarchie + auth store étendu (hasRole, isBureau) - Refactor useBovineColumns : variants withPrices/withoutPrices × inventory/case, gate par isBureau - Inventory page : Export/Rafraîchir conditionnés par isBureau - Ajout du rôle dans la const ROLE pour le form admin user Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import {defineStore} from 'pinia'
|
||||
import type {UserData} from '~/services/dto/user-data'
|
||||
import {getCurrentUser, createUser, updateUser, login, logout} from '~/services/auth'
|
||||
import type {UserPayload} from "~/services/dto/user-data";
|
||||
import {ROLE} from '~/utils/constants'
|
||||
import {userHasRole} from '~/utils/roles'
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
state: () => ({
|
||||
@@ -12,7 +12,9 @@ export const useAuthStore = defineStore('auth', {
|
||||
}),
|
||||
getters: {
|
||||
isAuthenticated: (state) => Boolean(state.user),
|
||||
isAdmin: (state) => Boolean(state.user?.roles?.includes(ROLE[0].value))
|
||||
hasRole: (state) => (role: string): boolean => userHasRole(state.user?.roles, role),
|
||||
isAdmin: (state) => userHasRole(state.user?.roles, 'ROLE_ADMIN'),
|
||||
isBureau: (state) => userHasRole(state.user?.roles, 'ROLE_BUREAU')
|
||||
},
|
||||
actions: {
|
||||
clearSession() {
|
||||
|
||||
Reference in New Issue
Block a user