diff --git a/resources/js/nostrApp.js b/resources/js/nostrApp.js index 0161073..75dda89 100644 --- a/resources/js/nostrApp.js +++ b/resources/js/nostrApp.js @@ -1,5 +1,6 @@ export default (livewireComponent) => ({ + isAllowed: livewireComponent.entangle('isAllowed', true), signThisEvent: livewireComponent.entangle('signThisEvent'), init() { diff --git a/resources/views/pages/association/election/[Election:year].blade.php b/resources/views/pages/association/election/[Election:year].blade.php index 72c58a0..bf89b1c 100644 --- a/resources/views/pages/association/election/[Election:year].blade.php +++ b/resources/views/pages/association/election/[Election:year].blade.php @@ -24,7 +24,9 @@ use function Livewire\Volt\{on}; name('association.election'); +state(['isAllowed' => false]); state(['currentPubkey' => null]); +state(['currentPleb' => null]); state(['events' => []]); state(['election' => fn() => $election]); state(['plebs' => []]); @@ -50,6 +52,12 @@ mount(function () { on([ 'nostrLoggedIn' => function ($pubkey) { $this->currentPubkey = $pubkey; + $this->currentPleb = \App\Models\EinundzwanzigPleb::query() + ->where('pubkey', $pubkey)->first(); + if($this->currentPleb->association_status->value < 3) { + return redirect()->route('association.profile'); + } + $this->isAllowed = true; }, ]); @@ -150,7 +158,7 @@ $signEvent = function ($event) { @volt -
+
@php $positions = [ @@ -189,7 +197,7 @@ $signEvent = function ($event) { ->values(); @endphp - +
diff --git a/resources/views/pages/association/election/index.blade.php b/resources/views/pages/association/election/index.blade.php index 0dfc2a6..5563acc 100644 --- a/resources/views/pages/association/election/index.blade.php +++ b/resources/views/pages/association/election/index.blade.php @@ -13,6 +13,8 @@ use function Livewire\Volt\{on}; name('association.elections'); +state(['isAllowed' => false]); +state(['currentPubkey' => null]); state(['elections' => []]); mount(function () { @@ -21,7 +23,16 @@ mount(function () { ->toArray(); }); -updated([ +on([ + 'nostrLoggedIn' => function ($pubkey) { + $this->currentPubkey = $pubkey; + $this->currentPleb = \App\Models\EinundzwanzigPleb::query() + ->where('pubkey', $pubkey)->first(); + if($this->currentPleb->association_status->value < 3) { + return redirect()->route('association.profile'); + } + $this->isAllowed = true; + }, ]); $saveElection = function ($index) { @@ -35,7 +46,7 @@ $saveElection = function ($index) { @volt -
+
@foreach($elections as $election)
diff --git a/resources/views/pages/association/members/admin.blade.php b/resources/views/pages/association/members/admin.blade.php index 6cdd35a..3b31504 100644 --- a/resources/views/pages/association/members/admin.blade.php +++ b/resources/views/pages/association/members/admin.blade.php @@ -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([ @volt -
+
@endvolt