diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-08 14:58:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-08 15:22:58 +0200 |
commit | e69219184b1a3262ec5e617d30337b6431c9840c (patch) | |
tree | 959b32e1ed28047052604941870563e946be9de1 /server/helpers/custom-validators/users.ts | |
parent | 6b09aba90dfe4c61331b66b1a6ef1f58ddc61485 (diff) | |
download | PeerTube-e69219184b1a3262ec5e617d30337b6431c9840c.tar.gz PeerTube-e69219184b1a3262ec5e617d30337b6431c9840c.tar.zst PeerTube-e69219184b1a3262ec5e617d30337b6431c9840c.zip |
Implement user blocking on server side
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index ce1323e94..4a0d79ae5 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -2,7 +2,7 @@ import 'express-validator' | |||
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import { UserRole } from '../../../shared' | 3 | import { UserRole } from '../../../shared' |
4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers' | 4 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers' |
5 | import { exists, isFileValid } from './misc' | 5 | import { exists, isFileValid, isBooleanValid } from './misc' |
6 | import { values } from 'lodash' | 6 | import { values } from 'lodash' |
7 | 7 | ||
8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS | 8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS |
@@ -29,17 +29,17 @@ function isUserDescriptionValid (value: string) { | |||
29 | return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.DESCRIPTION)) | 29 | return value === null || (exists(value) && validator.isLength(value, CONSTRAINTS_FIELDS.USERS.DESCRIPTION)) |
30 | } | 30 | } |
31 | 31 | ||
32 | function isBoolean (value: any) { | ||
33 | return typeof value === 'boolean' || (typeof value === 'string' && validator.isBoolean(value)) | ||
34 | } | ||
35 | |||
36 | const nsfwPolicies = values(NSFW_POLICY_TYPES) | 32 | const nsfwPolicies = values(NSFW_POLICY_TYPES) |
37 | function isUserNSFWPolicyValid (value: any) { | 33 | function isUserNSFWPolicyValid (value: any) { |
38 | return exists(value) && nsfwPolicies.indexOf(value) !== -1 | 34 | return exists(value) && nsfwPolicies.indexOf(value) !== -1 |
39 | } | 35 | } |
40 | 36 | ||
41 | function isUserAutoPlayVideoValid (value: any) { | 37 | function isUserAutoPlayVideoValid (value: any) { |
42 | return isBoolean(value) | 38 | return isBooleanValid(value) |
39 | } | ||
40 | |||
41 | function isUserBlockedValid (value: any) { | ||
42 | return isBooleanValid(value) | ||
43 | } | 43 | } |
44 | 44 | ||
45 | function isUserRoleValid (value: any) { | 45 | function isUserRoleValid (value: any) { |
@@ -57,6 +57,7 @@ function isAvatarFile (files: { [ fieldname: string ]: Express.Multer.File[] } | | |||
57 | // --------------------------------------------------------------------------- | 57 | // --------------------------------------------------------------------------- |
58 | 58 | ||
59 | export { | 59 | export { |
60 | isUserBlockedValid, | ||
60 | isUserPasswordValid, | 61 | isUserPasswordValid, |
61 | isUserRoleValid, | 62 | isUserRoleValid, |
62 | isUserVideoQuotaValid, | 63 | isUserVideoQuotaValid, |