'handleNostrLoggedOut', 'nostrLoggedIn' => 'handleNostrLoggedIn', ]; public function mount(): void { $this->elections = Election::query() ->get() ->toArray(); $nostrUser = NostrAuth::user(); if ($nostrUser) { $this->currentPubkey = $nostrUser->getPubkey(); $this->isAllowed = Gate::forUser($nostrUser)->allows('update', Election::query()->first() ?? new Election); } } public function handleNostrLoggedIn(string $pubkey): void { NostrAuth::login($pubkey); $this->currentPubkey = $pubkey; $this->currentPleb = EinundzwanzigPleb::query() ->where('pubkey', $pubkey)->first(); $nostrUser = NostrAuth::user(); $this->isAllowed = $nostrUser && Gate::forUser($nostrUser)->allows('update', Election::query()->first() ?? new Election); } public function handleNostrLoggedOut(): void { NostrAuth::logout(); $this->currentPubkey = null; $this->currentPleb = null; $this->isAllowed = false; } public function saveElection($index): void { $election = $this->elections[$index]; $electionModel = Election::find($election['id']); Gate::forUser(NostrAuth::user())->authorize('update', $electionModel); $electionModel->candidates = $election['candidates']; $electionModel->save(); } }; ?>
@if($isAllowed)
@foreach($elections as $election)
{{ $election['year'] }}
Kandidaten
Speichern
@endforeach
@else
Einstellungen können nicht bearbeitet werden

Zugriff auf die Wahl-Einstellungen ist nur für spezielle autorisierte Benutzer möglich.

@if(!NostrAuth::check()) Bitte melde dich zunächst mit Nostr an. @else Dein Benutzer-Account ist nicht für diese Funktion autorisiert. Bitte kontaktiere den Vorstand, wenn du Zugriff benötigst. @endif

@endif