X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fmodels%2Fusers%2Fuser-role.ts;h=94413abca3fbc4927b82be6e8dca2a34da051706;hb=c04816108e8ec62eb29caf82806f3927dc5eb85a;hp=cc32c768d9dace81751877154afdb7fbd0d65535;hpb=954605a804da399317ca62afa2fb9244afa11ebf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index cc32c768d..94413abca 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts @@ -1,36 +1,6 @@ -import { UserRight } from './user-right.enum' - // Keep the order export 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 - ], - - [UserRole.USER]: [] -} - -export function hasUserRight (userRole: UserRole, userRight: UserRight) { - const userRights = userRoleRights[userRole] - - return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1 -}