feat: add permission checks for election views

- Add permission checks to the election index and election year views.
- Show election views only to users with a certain association status.
- Update nostrApp.js to entangle the 'isAllowed' state.
This commit is contained in:
fsociety
2024-09-30 17:09:25 +02:00
parent 9b23a7f6e7
commit 241cc9659f
4 changed files with 32 additions and 5 deletions

View File

@@ -13,12 +13,19 @@ use function Livewire\Volt\{on};
name('association.members.admin');
state(['isAllowed' => false]);
state(['currentPubkey' => null]);
state(['members' => []]);
on([
'nostrLoggedIn' => function ($pubkey) {
$this->currentPubkey = $pubkey;
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
->where('pubkey', $pubkey)->first();
if($this->currentPubkey !== '0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033') {
return redirect()->route('association.profile');
}
$this->isAllowed = true;
},
]);
@@ -26,7 +33,7 @@ on([
<x-layouts.app title="{{ __('Mitglieder') }}">
@volt
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto" x-show="isAllowed" x-data="{isAllowed: $wire.entangle('isAllowed').live}" x-cloak>
<livewire:einundzwanzig-pleb-table/>
</div>
@endvolt