mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Reorganize shared models
This commit is contained in:
parent
583eb04b54
commit
bd45d503e5
59 changed files with 155 additions and 144 deletions
1
shared/core-utils/users/index.ts
Normal file
1
shared/core-utils/users/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from './user-role'
|
35
shared/core-utils/users/user-role.ts
Normal file
35
shared/core-utils/users/user-role.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { UserRight, UserRole } from '../../models/users'
|
||||
|
||||
export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
|
||||
[UserRole.USER]: 'User',
|
||||
[UserRole.MODERATOR]: 'Moderator',
|
||||
[UserRole.ADMINISTRATOR]: 'Administrator'
|
||||
}
|
||||
|
||||
const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
|
||||
[UserRole.ADMINISTRATOR]: [
|
||||
UserRight.ALL
|
||||
],
|
||||
|
||||
[UserRole.MODERATOR]: [
|
||||
UserRight.MANAGE_VIDEO_BLACKLIST,
|
||||
UserRight.MANAGE_ABUSES,
|
||||
UserRight.REMOVE_ANY_VIDEO,
|
||||
UserRight.REMOVE_ANY_VIDEO_CHANNEL,
|
||||
UserRight.REMOVE_ANY_VIDEO_PLAYLIST,
|
||||
UserRight.REMOVE_ANY_VIDEO_COMMENT,
|
||||
UserRight.UPDATE_ANY_VIDEO,
|
||||
UserRight.SEE_ALL_VIDEOS,
|
||||
UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
|
||||
UserRight.MANAGE_SERVERS_BLOCKLIST,
|
||||
UserRight.MANAGE_USERS
|
||||
],
|
||||
|
||||
[UserRole.USER]: []
|
||||
}
|
||||
|
||||
export function hasUserRight (userRole: UserRole, userRight: UserRight) {
|
||||
const userRights = userRoleRights[userRole]
|
||||
|
||||
return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue