From: Daniel Karbach Date: Wed, 6 Apr 2022 11:40:23 +0000 (+0200) Subject: remove absurd admin permissions X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=eca3f0074e6f9e882b91893e554ce249e25338de;p=alttp.git remove absurd admin permissions --- diff --git a/app/Policies/ParticipantPolicy.php b/app/Policies/ParticipantPolicy.php index 8622d12..fb86b73 100644 --- a/app/Policies/ParticipantPolicy.php +++ b/app/Policies/ParticipantPolicy.php @@ -18,7 +18,7 @@ class ParticipantPolicy */ public function viewAny(User $user) { - return $user->isAdmin(); + return true; } /** @@ -30,7 +30,7 @@ class ParticipantPolicy */ public function view(User $user, Participant $participant) { - return $user->isAdmin(); + return true; } /** @@ -53,7 +53,7 @@ class ParticipantPolicy */ public function update(User $user, Participant $participant) { - return $user->isAdmin(); + return false; } /** diff --git a/app/Policies/ProtocolPolicy.php b/app/Policies/ProtocolPolicy.php index 186fe09..689e0c2 100644 --- a/app/Policies/ProtocolPolicy.php +++ b/app/Policies/ProtocolPolicy.php @@ -18,7 +18,7 @@ class ProtocolPolicy */ public function viewAny(User $user) { - return $user->role === 'admin'; + return false; } /** @@ -30,7 +30,7 @@ class ProtocolPolicy */ public function view(User $user, Protocol $protocol) { - return $user->role === 'admin'; + return $user->isTournamentCrew($protocol->tournament); } /** diff --git a/app/Policies/RoundPolicy.php b/app/Policies/RoundPolicy.php index f9f2d46..ec71a89 100644 --- a/app/Policies/RoundPolicy.php +++ b/app/Policies/RoundPolicy.php @@ -41,7 +41,7 @@ class RoundPolicy */ public function create(User $user) { - return $user->role === 'admin'; + return false; } /** @@ -53,7 +53,7 @@ class RoundPolicy */ public function update(User $user, Round $round) { - return $user->role === 'admin'; + return false; } /** @@ -118,7 +118,7 @@ class RoundPolicy */ public function setSeed(User $user, Round $round) { - return !$round->locked && ($user->isAdmin() || $user->isRunner($round->tournament) || $user->isTournamentAdmin($round->tournament)); + return !$round->locked && ($user->isRunner($round->tournament) || $user->isTournamentAdmin($round->tournament)); } /** @@ -130,7 +130,7 @@ class RoundPolicy */ public function lock(User $user, Round $round) { - return !$round->tournament->locked && ($user->isAdmin() || $user->isTournamentAdmin($round->tournament)); + return !$round->tournament->locked && ($user->isTournamentAdmin($round->tournament)); } /** diff --git a/app/Policies/TournamentPolicy.php b/app/Policies/TournamentPolicy.php index 66ab1f6..5942b7f 100644 --- a/app/Policies/TournamentPolicy.php +++ b/app/Policies/TournamentPolicy.php @@ -41,7 +41,7 @@ class TournamentPolicy */ public function create(User $user) { - return $user->role === 'admin'; + return $user->isAdmin(); } /** @@ -53,7 +53,7 @@ class TournamentPolicy */ public function update(User $user, Tournament $tournament) { - return $user->role === 'admin'; + return $user->isTournamentAdmin($tournament); } /** @@ -101,7 +101,7 @@ class TournamentPolicy */ public function addRound(User $user, Tournament $tournament) { - return !$tournament->locked && ($user->isAdmin() || $user->isRunner($tournament) || $user->isTournamentAdmin($tournament)); + return !$tournament->locked && ($user->isRunner($tournament) || $user->isTournamentAdmin($tournament)); } /** @@ -113,7 +113,7 @@ class TournamentPolicy */ public function viewProtocol(User $user, Tournament $tournament) { - return $user->isAdmin() || $user->isTournamentCrew($tournament); + return $user->isTournamentCrew($tournament); } } diff --git a/resources/js/helpers/permissions.js b/resources/js/helpers/permissions.js index 2ff823a..8b8c596 100644 --- a/resources/js/helpers/permissions.js +++ b/resources/js/helpers/permissions.js @@ -37,17 +37,17 @@ export const hasFinished = (user, round) => export const mayAddRounds = (user, tournament) => !tournament.locked && - (isAdmin(user) || isRunner(user, tournament) || isTournamentAdmin(user, tournament)); + (isRunner(user, tournament) || isTournamentAdmin(user, tournament)); export const mayLockRound = (user, tournament) => - !tournament.locked && (isAdmin(user) || isTournamentAdmin(user, tournament)); + !tournament.locked && isTournamentAdmin(user, tournament); export const maySetSeed = (user, tournament, round) => !round.locked && - (isAdmin(user) || isRunner(user, tournament) || isTournamentAdmin(user, tournament)); + (isRunner(user, tournament) || isTournamentAdmin(user, tournament)); export const mayViewProtocol = (user, tournament) => - isAdmin(user) || isTournamentCrew(user, tournament); + isTournamentCrew(user, tournament); export const maySeeResults = (user, tournament, round) => round.locked || @@ -59,7 +59,7 @@ export const maySeeResults = (user, tournament, round) => // Users export const mayEditNickname = (user, subject) => - isAdmin(user) || isSameUser(user, subject); + isSameUser(user, subject); export const mayEditStreamLink = (user, subject) => - isAdmin(user) || isSameUser(user, subject); + isSameUser(user, subject);