aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/users.ts11
1 files changed, 5 insertions, 6 deletions
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 @@
1import { values } from 'lodash'
2import * as validator from 'validator' 1import * as validator from 'validator'
3import 'express-validator' 2import 'express-validator'
4 3
5import { exists } from './misc' 4import { exists } from './misc'
6import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' 5import { CONSTRAINTS_FIELDS } from '../../initializers'
7import { UserRole } from '../../../shared' 6import { UserRole } from '../../../shared'
8 7
9const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS 8const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
@@ -12,10 +11,6 @@ function isUserPasswordValid (value: string) {
12 return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD) 11 return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD)
13} 12}
14 13
15function isUserRoleValid (value: string) {
16 return values(USER_ROLES).indexOf(value as UserRole) !== -1
17}
18
19function isUserVideoQuotaValid (value: string) { 14function isUserVideoQuotaValid (value: string) {
20 return exists(value) && validator.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA) 15 return exists(value) && validator.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA)
21} 16}
@@ -30,6 +25,10 @@ function isUserDisplayNSFWValid (value: any) {
30 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) 25 return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value))
31} 26}
32 27
28function isUserRoleValid (value: any) {
29 return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined
30}
31
33// --------------------------------------------------------------------------- 32// ---------------------------------------------------------------------------
34 33
35export { 34export {