aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/users/user-role.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-06 14:58:01 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:28:14 +0200
commitbd45d503e5d007e730f4e81dccd7e7864c9a85cc (patch)
treeb78df768b8253ba401232c17da940cea016c9960 /shared/models/users/user-role.ts
parent583eb04b541175035d6d452ca626a96ebf2b7437 (diff)
downloadPeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.gz
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.zst
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.zip
Reorganize shared models
Diffstat (limited to 'shared/models/users/user-role.ts')
-rw-r--r--shared/models/users/user-role.ts36
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 @@
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}