From 954605a804da399317ca62afa2fb9244afa11ebf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Oct 2017 16:55:03 +0200 Subject: Support roles with rights and add moderator role --- server/helpers/custom-validators/users.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index c180eccda..f423d6317 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -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 { -- cgit v1.2.3