Fixed RLS and added visual feedback on dashboard
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { PhFilePlus, PhPencil, PhPencilSimpleLine, PhTrash } from "@phosphor-icons/vue";
|
import { PhArchive, PhFileDashed, PhFilePlus, PhPencil, PhPencilSimpleLine, PhTrash } from "@phosphor-icons/vue";
|
||||||
import type { World } from "~/models/World";
|
import type { World } from "~/models/World";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
@@ -41,8 +41,18 @@ const updatedAt = computed<string>(() => props.world.updatedAt ? DateTime.fromIS
|
|||||||
' hover:bg-slate-50 dark:hover:text-slate-900 dark:hover:bg-slate-300 dark:border-slate-500 dark:focus-within:outline-slate-100': world.color === 'white',
|
' hover:bg-slate-50 dark:hover:text-slate-900 dark:hover:bg-slate-300 dark:border-slate-500 dark:focus-within:outline-slate-100': world.color === 'white',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<UiCardHeader>
|
<UiCardHeader class="gap-4">
|
||||||
<UiCardTitle>{{ world.name }}</UiCardTitle>
|
<UiCardTitle>
|
||||||
|
{{ world.name }}
|
||||||
|
</UiCardTitle>
|
||||||
|
<div v-if="world.state === 'draft'" class="flex items-center gap-1 text-sm">
|
||||||
|
<PhFileDashed size="20" weight="fill" />
|
||||||
|
<span>{{ $t('ui.contentState.draft') }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="world.state === 'archived'" class="flex items-center gap-1 text-sm">
|
||||||
|
<PhArchive size="20" weight="fill" />
|
||||||
|
<span>{{ $t('ui.contentState.archived') }}</span>
|
||||||
|
</div>
|
||||||
</UiCardHeader>
|
</UiCardHeader>
|
||||||
<UiCardContent>
|
<UiCardContent>
|
||||||
<p class="italic">{{ world.description }}</p>
|
<p class="italic">{{ world.description }}</p>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function handleClose() {
|
|||||||
<PhX size="20" />
|
<PhX size="20" />
|
||||||
</UiButton>
|
</UiButton>
|
||||||
|
|
||||||
<WorldFormEdit :world @on-changed-name="onChangedName" @on-close="handleClose" />
|
<WorldFormUpdate :world @on-changed-name="onChangedName" @on-close="handleClose" />
|
||||||
</UiAlertDialogContent>
|
</UiAlertDialogContent>
|
||||||
</UiAlertDialog>
|
</UiAlertDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -225,12 +225,21 @@ create policy "Allow GMs to delete their worlds" on public.worlds for delete usi
|
|||||||
-- Calendar policies
|
-- Calendar policies
|
||||||
create policy "Allow anonymous access to published calendars" on public.calendars
|
create policy "Allow anonymous access to published calendars" on public.calendars
|
||||||
for select
|
for select
|
||||||
using (state = 'published');
|
using (
|
||||||
|
exists (
|
||||||
|
select 1
|
||||||
|
from public.worlds
|
||||||
|
where worlds.id = calendars.world_id
|
||||||
|
and worlds.state = 'published'
|
||||||
|
and calendars.state = 'published'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
create policy "Allow GMs to see their calendars" on public.calendars for select using (
|
create policy "Allow GMs to see their calendars" on public.calendars for select using (
|
||||||
exists (
|
exists (
|
||||||
select 1 from worlds
|
select 1 from worlds
|
||||||
where worlds.id = calendars.world_id
|
where worlds.id = calendars.world_id
|
||||||
|
and worlds.gm_id = auth.uid()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
create policy "Allow GMs to add calendars to their worldd" on public.calendars for insert with check (
|
create policy "Allow GMs to add calendars to their worldd" on public.calendars for insert with check (
|
||||||
@@ -258,9 +267,11 @@ create policy "Allow anonymous access to months in published calendars" ON publi
|
|||||||
using (
|
using (
|
||||||
exists (
|
exists (
|
||||||
select 1
|
select 1
|
||||||
from public.calendars
|
from public.calendars c
|
||||||
where calendars.id = calendar_months.calendar_id
|
join public.worlds w on w.id = c.world_id
|
||||||
and calendars.state = 'published'
|
where c.id = calendar_months.calendar_id
|
||||||
|
and c.state = 'published'
|
||||||
|
and w.state = 'published'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user