]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/users/user-role.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / models / users / user-role.ts
CommitLineData
954605a8
C
1import { UserRight } from './user-right.enum'
2
3// Keep the order
4export enum UserRole {
5 ADMINISTRATOR = 0,
6 MODERATOR = 1,
7 USER = 2
8}
9
ca6d3622 10export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
954605a8
C
11 [UserRole.USER]: 'User',
12 [UserRole.MODERATOR]: 'Moderator',
13 [UserRole.ADMINISTRATOR]: 'Administrator'
14}
15
ca6d3622 16const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
954605a8
C
17 [UserRole.ADMINISTRATOR]: [
18 UserRight.ALL
19 ],
20
21 [UserRole.MODERATOR]: [
22 UserRight.MANAGE_VIDEO_BLACKLIST,
23 UserRight.MANAGE_VIDEO_ABUSES,
24 UserRight.REMOVE_ANY_VIDEO,
4cb6d457 25 UserRight.REMOVE_ANY_VIDEO_CHANNEL,
418d092a 26 UserRight.REMOVE_ANY_VIDEO_PLAYLIST,
6221f311 27 UserRight.REMOVE_ANY_VIDEO_COMMENT,
1cd3facc 28 UserRight.UPDATE_ANY_VIDEO,
b44164bb
C
29 UserRight.SEE_ALL_VIDEOS,
30 UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
f7cc67b4
C
31 UserRight.MANAGE_SERVERS_BLOCKLIST,
32 UserRight.MANAGE_USERS
954605a8
C
33 ],
34
35 [UserRole.USER]: []
36}
37
38export function hasUserRight (userRole: UserRole, userRight: UserRight) {
39 const userRights = userRoleRights[userRole]
40
41 return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1
42}