🚀 Refactor: Centralize isBoardMember logic in EinundzwanzigPleb model and replace redundant checks

This commit is contained in:
HolgerHatGarKeineNode
2026-05-18 22:04:45 +02:00
parent cb61d9d543
commit 3b855e9517
14 changed files with 86 additions and 75 deletions
+3 -14
View File
@@ -29,7 +29,7 @@ class ElectionPolicy
*/
public function create(NostrUser $user): bool
{
return $this->isBoardMember($user);
return $user->isBoardMember();
}
/**
@@ -38,7 +38,7 @@ class ElectionPolicy
*/
public function update(NostrUser $user, Election $election): bool
{
return $this->isBoardMember($user);
return $user->isBoardMember();
}
/**
@@ -47,7 +47,7 @@ class ElectionPolicy
*/
public function delete(NostrUser $user, Election $election): bool
{
return $this->isBoardMember($user);
return $user->isBoardMember();
}
/**
@@ -64,15 +64,4 @@ class ElectionPolicy
return $pleb->association_status->value >= 3;
}
private function isBoardMember(NostrUser $user): bool
{
$pleb = $user->getPleb();
if (! $pleb) {
return false;
}
return in_array($pleb->npub, config('einundzwanzig.config.current_board'), true);
}
}