]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/permissions.js
tournament admins
[alttp.git] / resources / js / helpers / permissions.js
index 23272d9ac14b0f561d53b1507d5fda79453d4d1d..21016f1a08f6786fecfdcbe775717ace91b8279b 100644 (file)
@@ -13,6 +13,16 @@ export const isParticipant = (user, tournament) =>
        user && tournament && tournament.participants &&
        tournament.participants.find(p => p.user && p.user.id == user.id);
 
+export const isRunner = (user, tournament) => {
+       const p = isParticipant(user, tournament);
+       return p && p.roles && p.roles.includes('runner');
+};
+
+export const isTournamentAdmin = (user, tournament) => {
+       const p = isParticipant(user, tournament);
+       return p && p.roles && p.roles.includes('admin');
+};
+
 export const hasFinished = (user, round) =>
        user && round && round.results &&
        round.results.find(r => r.user_id == user.id && r.has_finished);
@@ -23,8 +33,8 @@ export const mayAddRounds = (user, tournament) =>
 export const maySetSeed = (user, tournament) =>
        isAdmin(user) || isParticipant(user, tournament);
 
-export const mayViewProtocol = user =>
-       isAdmin(user);
+export const mayViewProtocol = (user, tournament) =>
+       isAdmin(user) || isTournamentAdmin(user, tournament);
 
 export const maySeeResults = (user, tournament, round) =>
        isAdmin(user) || hasFinished(user, round) || Round.isComplete(tournament, round);