X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fmodels%2Fusers%2Fuser-role.ts;h=687a2aa0d5613799548673219ff502fa63c68d01;hb=cba7977552e909ea0ea4dc526788a9166ad5f535;hp=d7020c0f2bf5b7a4bd339d51eb66e4fe23058e29;hpb=1cd3facc3de899ac864e979cd6d6a704b712cce3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index d7020c0f2..687a2aa0d 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts @@ -1,40 +1,6 @@ -import { UserRight } from './user-right.enum' - // Keep the order -export enum UserRole { +export const enum UserRole { ADMINISTRATOR = 0, MODERATOR = 1, USER = 2 } - -// TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed -export const USER_ROLE_LABELS: { [ id: number ]: string } = { - [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, - UserRight.UPDATE_ANY_VIDEO, - UserRight.SEE_ALL_VIDEOS - ], - - [UserRole.USER]: [] -} - -export function hasUserRight (userRole: UserRole, userRight: UserRight) { - const userRights = userRoleRights[userRole] - - return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1 -}