aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/users
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/core-utils/users
parent583eb04b541175035d6d452ca626a96ebf2b7437 (diff)
downloadPeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.gz
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.zst
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.zip
Reorganize shared models
Diffstat (limited to 'shared/core-utils/users')
-rw-r--r--shared/core-utils/users/index.ts1
-rw-r--r--shared/core-utils/users/user-role.ts35
2 files changed, 36 insertions, 0 deletions
diff --git a/shared/core-utils/users/index.ts b/shared/core-utils/users/index.ts
new file mode 100644
index 000000000..1cbf0af1b
--- /dev/null
+++ b/shared/core-utils/users/index.ts
@@ -0,0 +1 @@
export * from './user-role'
diff --git a/shared/core-utils/users/user-role.ts b/shared/core-utils/users/user-role.ts
new file mode 100644
index 000000000..2b322faf3
--- /dev/null
+++ b/shared/core-utils/users/user-role.ts
@@ -0,0 +1,35 @@
1import { UserRight, UserRole } from '../../models/users'
2
3export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
4 [UserRole.USER]: 'User',
5 [UserRole.MODERATOR]: 'Moderator',
6 [UserRole.ADMINISTRATOR]: 'Administrator'
7}
8
9const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
10 [UserRole.ADMINISTRATOR]: [
11 UserRight.ALL
12 ],
13
14 [UserRole.MODERATOR]: [
15 UserRight.MANAGE_VIDEO_BLACKLIST,
16 UserRight.MANAGE_ABUSES,
17 UserRight.REMOVE_ANY_VIDEO,
18 UserRight.REMOVE_ANY_VIDEO_CHANNEL,
19 UserRight.REMOVE_ANY_VIDEO_PLAYLIST,
20 UserRight.REMOVE_ANY_VIDEO_COMMENT,
21 UserRight.UPDATE_ANY_VIDEO,
22 UserRight.SEE_ALL_VIDEOS,
23 UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
24 UserRight.MANAGE_SERVERS_BLOCKLIST,
25 UserRight.MANAGE_USERS
26 ],
27
28 [UserRole.USER]: []
29}
30
31export function hasUserRight (userRole: UserRole, userRight: UserRight) {
32 const userRights = userRoleRights[userRole]
33
34 return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
35}