aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/users
diff options
context:
space:
mode:
Diffstat (limited to 'shared/models/users')
-rw-r--r--shared/models/users/user-flag.model.ts2
-rw-r--r--shared/models/users/user-notification-setting.model.ts2
-rw-r--r--shared/models/users/user-right.enum.ts2
-rw-r--r--shared/models/users/user-role.ts36
4 files changed, 3 insertions, 39 deletions
diff --git a/shared/models/users/user-flag.model.ts b/shared/models/users/user-flag.model.ts
index b94262d5e..b791a1263 100644
--- a/shared/models/users/user-flag.model.ts
+++ b/shared/models/users/user-flag.model.ts
@@ -1,4 +1,4 @@
1export enum UserAdminFlag { 1export const enum UserAdminFlag {
2 NONE = 0, 2 NONE = 0,
3 BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0 3 BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0
4} 4}
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts
index c7590fa8a..473148062 100644
--- a/shared/models/users/user-notification-setting.model.ts
+++ b/shared/models/users/user-notification-setting.model.ts
@@ -1,4 +1,4 @@
1export enum UserNotificationSettingValue { 1export const enum UserNotificationSettingValue {
2 NONE = 0, 2 NONE = 0,
3 WEB = 1 << 0, 3 WEB = 1 << 0,
4 EMAIL = 1 << 1 4 EMAIL = 1 << 1
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts
index 4a7ae4373..4c3d9e7c8 100644
--- a/shared/models/users/user-right.enum.ts
+++ b/shared/models/users/user-right.enum.ts
@@ -1,4 +1,4 @@
1export enum UserRight { 1export const enum UserRight {
2 ALL, 2 ALL,
3 3
4 MANAGE_USERS, 4 MANAGE_USERS,
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 @@
1import { UserRight } from './user-right.enum'
2
3// Keep the order 1// Keep the order
4export enum UserRole { 2export enum UserRole {
5 ADMINISTRATOR = 0, 3 ADMINISTRATOR = 0,
6 MODERATOR = 1, 4 MODERATOR = 1,
7 USER = 2 5 USER = 2
8} 6}
9
10export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
11 [UserRole.USER]: 'User',
12 [UserRole.MODERATOR]: 'Moderator',
13 [UserRole.ADMINISTRATOR]: 'Administrator'
14}
15
16const 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
38export function hasUserRight (userRole: UserRole, userRight: UserRight) {
39 const userRights = userRoleRights[userRole]
40
41 return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
42}