Restrict proclamation editing and content to Super admins only
- Only roleId <= 1 (SUPER) can create/edit/delete proclamations - Content field is stripped from records for non-Super users - Content field is hidden from the form for non-Super users - Server actions reject upsert/delete from non-Super users
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
let { data, form }: PageProps = $props();
|
||||
|
||||
const config = getModelConfig('proclamations')!;
|
||||
const canDelete = $derived((data.adminUser?.roleId ?? 4) <= 2);
|
||||
const viewerRoleId = $derived(data.adminUser?.roleId ?? 4);
|
||||
const isSuper = $derived(viewerRoleId <= 1);
|
||||
const canDelete = $derived(viewerRoleId <= 2);
|
||||
|
||||
let modalOpen = $state(false);
|
||||
let editingRecord = $state<Record<string, unknown> | null>(null);
|
||||
@@ -63,8 +65,8 @@
|
||||
searchFields={config.searchFields}
|
||||
fieldTypes={config.fieldTypes}
|
||||
singular={config.displayNameSingular}
|
||||
onRowClick={openEdit}
|
||||
onNew={openCreate}
|
||||
onRowClick={isSuper ? openEdit : undefined}
|
||||
onNew={isSuper ? openCreate : undefined}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -83,6 +85,7 @@
|
||||
categories={data.categories}
|
||||
{fieldErrors}
|
||||
{formError}
|
||||
{isSuper}
|
||||
submitLabel={editingRecord ? 'Update' : 'Create'}
|
||||
/>
|
||||
</AdminModal>
|
||||
|
||||
Reference in New Issue
Block a user