]> git.localhorst.tv Git - alttp.git/blob - resources/js/helpers/permissions.js
basic result display
[alttp.git] / resources / js / helpers / permissions.js
1 /// NOTE: These permissions are for UI cosmetics only!
2 /// They should be in sync with the backend Policies.
3
4 export const isAdmin = user => user && user.role === 'admin';
5
6 export const isSameUser = (user, subject) => user && subject && user.id === subject.id;
7
8 // Tournaments
9
10 export const isParticipant = (user, tournament) =>
11         user && tournament && tournament.participants &&
12         tournament.participants.find(p => p.user && p.user.id == user.id);
13
14 export const mayAddRounds = (user, tournament) =>
15         isAdmin(user) || isParticipant(user, tournament);