X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fmodels%2Fusers%2Fuser-role.ts;h=687a2aa0d5613799548673219ff502fa63c68d01;hb=cba7977552e909ea0ea4dc526788a9166ad5f535;hp=0e75444f8f35f5667ae9f361aeaf3ffe6fef5ab7;hpb=4cb6d4578893db310297d7e118ce2fb7ecb952a3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 0e75444f8..687a2aa0d 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts @@ -1,37 +1,6 @@ -import { UserRight } from './user-right.enum' - // Keep the order -export enum UserRole { +export const enum UserRole { ADMINISTRATOR = 0, MODERATOR = 1, USER = 2 } - -export const USER_ROLE_LABELS = { - [UserRole.USER]: 'User', - [UserRole.MODERATOR]: 'Moderator', - [UserRole.ADMINISTRATOR]: 'Administrator' -} - -// TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed -const userRoleRights: { [ id: number ]: UserRight[] } = { - [UserRole.ADMINISTRATOR]: [ - UserRight.ALL - ], - - [UserRole.MODERATOR]: [ - UserRight.MANAGE_VIDEO_BLACKLIST, - UserRight.MANAGE_VIDEO_ABUSES, - UserRight.REMOVE_ANY_VIDEO, - UserRight.REMOVE_ANY_VIDEO_CHANNEL, - UserRight.REMOVE_ANY_VIDEO_COMMENT - ], - - [UserRole.USER]: [] -} - -export function hasUserRight (userRole: UserRole, userRight: UserRight) { - const userRights = userRoleRights[userRole] - - return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1 -}