diff options
Diffstat (limited to 'shared/models/users/user-role.ts')
-rw-r--r-- | shared/models/users/user-role.ts | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 772988c0c..94413abca 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts | |||
@@ -1,42 +1,6 @@ | |||
1 | import { UserRight } from './user-right.enum' | ||
2 | |||
3 | // Keep the order | 1 | // Keep the order |
4 | export enum UserRole { | 2 | export enum UserRole { |
5 | ADMINISTRATOR = 0, | 3 | ADMINISTRATOR = 0, |
6 | MODERATOR = 1, | 4 | MODERATOR = 1, |
7 | USER = 2 | 5 | USER = 2 |
8 | } | 6 | } |
9 | |||
10 | export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = { | ||
11 | [UserRole.USER]: 'User', | ||
12 | [UserRole.MODERATOR]: 'Moderator', | ||
13 | [UserRole.ADMINISTRATOR]: 'Administrator' | ||
14 | } | ||
15 | |||
16 | const userRoleRights: { [ id in UserRole ]: UserRight[] } = { | ||
17 | [UserRole.ADMINISTRATOR]: [ | ||
18 | UserRight.ALL | ||
19 | ], | ||
20 | |||
21 | [UserRole.MODERATOR]: [ | ||
22 | UserRight.MANAGE_VIDEO_BLACKLIST, | ||
23 | UserRight.MANAGE_ABUSES, | ||
24 | UserRight.REMOVE_ANY_VIDEO, | ||
25 | UserRight.REMOVE_ANY_VIDEO_CHANNEL, | ||
26 | UserRight.REMOVE_ANY_VIDEO_PLAYLIST, | ||
27 | UserRight.REMOVE_ANY_VIDEO_COMMENT, | ||
28 | UserRight.UPDATE_ANY_VIDEO, | ||
29 | UserRight.SEE_ALL_VIDEOS, | ||
30 | UserRight.MANAGE_ACCOUNTS_BLOCKLIST, | ||
31 | UserRight.MANAGE_SERVERS_BLOCKLIST, | ||
32 | UserRight.MANAGE_USERS | ||
33 | ], | ||
34 | |||
35 | [UserRole.USER]: [] | ||
36 | } | ||
37 | |||
38 | export function hasUserRight (userRole: UserRole, userRight: UserRight) { | ||
39 | const userRights = userRoleRights[userRole] | ||
40 | |||
41 | return userRights.includes(UserRight.ALL) || userRights.includes(userRight) | ||
42 | } | ||