feat(permissions) : add role-based UI guards and readonly mode for viewers
- Add usePermissions composable (isAdmin, canEdit, canView) - Password-protected profile login with modal on profiles page - Disable all form fields for ROLE_VIEWER across edit/create pages - Show navigation buttons (Modifier/Consulter) for all roles, hide delete for viewers - Add readonly prop to ModelTypeForm for category pages - Disable modal fields (sites, constructeurs) for viewers - Guard /admin routes in middleware Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<h2 class="text-2xl font-bold">
|
||||
Sites
|
||||
</h2>
|
||||
<button class="btn btn-primary" @click="openCreateSiteModal">
|
||||
<button v-if="canEdit" class="btn btn-primary" @click="openCreateSiteModal">
|
||||
<IconLucidePlus class="w-5 h-5 mr-2" aria-hidden="true" />
|
||||
Ajouter un site
|
||||
</button>
|
||||
@@ -30,7 +30,7 @@
|
||||
<p class="text-gray-500 mb-4">
|
||||
Commencez par ajouter votre premier site.
|
||||
</p>
|
||||
<button class="btn btn-primary" @click="openCreateSiteModal">
|
||||
<button v-if="canEdit" class="btn btn-primary" @click="openCreateSiteModal">
|
||||
Ajouter un site
|
||||
</button>
|
||||
</div>
|
||||
@@ -50,6 +50,7 @@
|
||||
<SiteCreateModal
|
||||
:visible="showAddSiteModal"
|
||||
:site="newSite"
|
||||
:disabled="!canEdit"
|
||||
@close="closeCreateModal"
|
||||
@submit="handleCreateSite"
|
||||
/>
|
||||
@@ -64,6 +65,7 @@
|
||||
:can-preview-document="canPreviewDocument"
|
||||
:document-icon="documentIcon"
|
||||
:format-size="formatSize"
|
||||
:disabled="!canEdit"
|
||||
@close="closeEditModal"
|
||||
@submit="handleUpdateSite"
|
||||
@remove-document="handleRemoveSiteDocument"
|
||||
@@ -83,6 +85,8 @@ import SiteCreateModal from '~/components/sites/SiteCreateModal.vue'
|
||||
import SiteEditModal from '~/components/sites/SiteEditModal.vue'
|
||||
import { useSiteManagement } from '~/composables/useSiteManagement'
|
||||
|
||||
const { canEdit } = usePermissions()
|
||||
|
||||
const {
|
||||
sites,
|
||||
loading,
|
||||
|
||||
Reference in New Issue
Block a user