1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Support roles with rights and add moderator role

This commit is contained in:
Chocobozzz 2017-10-27 16:55:03 +02:00
parent e02573ad67
commit 954605a804
No known key found for this signature in database
GPG key ID: 583A612D890159BE
51 changed files with 378 additions and 139 deletions

View file

@ -1,9 +1,8 @@
import { values } from 'lodash'
import * as validator from 'validator'
import 'express-validator'
import { exists } from './misc'
import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers'
import { CONSTRAINTS_FIELDS } from '../../initializers'
import { UserRole } from '../../../shared'
const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
@ -12,10 +11,6 @@ function isUserPasswordValid (value: string) {
return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD)
}
function isUserRoleValid (value: string) {
return values(USER_ROLES).indexOf(value as UserRole) !== -1
}
function isUserVideoQuotaValid (value: string) {
return exists(value) && validator.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA)
}
@ -30,6 +25,10 @@ function isUserDisplayNSFWValid (value: any) {
return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
}
function isUserRoleValid (value: any) {
return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined
}
// ---------------------------------------------------------------------------
export {