]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/permissions.js
sort channels on restream add form
[alttp.git] / resources / js / helpers / permissions.js
index 54bf905fe473a9224419c4325e1b6b9b5c72d5a2..706e676ab692d5b44ec606e66ad8fc01c13a372f 100644 (file)
@@ -4,6 +4,9 @@
 import * as Episode from './Episode';
 import Round from './Round';
 
+export const hasGlobalRole = (user, role) =>
+       user && role && user.global_roles && user.global_roles.includes(role);
+
 export const isAdmin = user => user && user.role === 'admin';
 
 export const isSameUser = (user, subject) => user && subject && user.id === subject.id;
@@ -14,6 +17,11 @@ export const isChannelAdmin = (user, channel) =>
        user && channel && user.channel_crews &&
                user.channel_crews.find(c => c.role === 'admin' && c.channel_id === channel.id);
 
+// Content
+
+export const mayEditContent = user =>
+       user && hasGlobalRole(user, 'content');
+
 // Episodes
 
 export const isCommentator = (user, episode) => {
@@ -147,6 +155,10 @@ export const maySeeResults = (user, tournament, round) =>
        isTournamentMonitor(user, tournament) ||
        Round.isComplete(tournament, round);
 
+// Twitch
+
+export const mayManageTwitchBot = user => isAdmin(user) || hasGlobalRole(user, 'twitch');
+
 // Users
 
 export const mayEditNickname = (user, subject) =>