2020-08-06 07:58:01 -05:00
|
|
|
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,
|
2021-12-13 08:29:13 -06:00
|
|
|
UserRight.MANAGE_ANY_VIDEO_CHANNEL,
|
2020-08-06 07:58:01 -05:00
|
|
|
UserRight.REMOVE_ANY_VIDEO,
|
|
|
|
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,
|
2020-11-13 09:38:23 -06:00
|
|
|
UserRight.MANAGE_USERS,
|
2023-01-19 02:27:16 -06:00
|
|
|
UserRight.SEE_ALL_COMMENTS,
|
|
|
|
UserRight.MANAGE_REGISTRATIONS
|
2020-08-06 07:58:01 -05:00
|
|
|
],
|
|
|
|
|
|
|
|
[UserRole.USER]: []
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hasUserRight (userRole: UserRole, userRight: UserRight) {
|
|
|
|
const userRights = userRoleRights[userRole]
|
|
|
|
|
|
|
|
return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
|
|
|
|
}
|