Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix scheduled privacy and verify email validations

Chocobozzz2b65c4e53511
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 1b7e004310..0c3df1cd08 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -1,7 +1,6 @@
import 'multer'
import * as validator from 'validator'
import { sep } from 'path'
-import toBoolean = require('validator/lib/toBoolean')
function exists (value: any) {
return value !== undefined && value !== null
@@ -52,7 +51,7 @@ function toIntOrNull (value: string) {
if (v === null || v === undefined) return v
if (typeof v === 'number') return v
- return validator.toInt(v)
+ return validator.toInt('' + v)
}
function toBooleanOrNull (value: any) {
@@ -61,7 +60,7 @@ function toBooleanOrNull (value: any) {
if (v === null || v === undefined) return v
if (typeof v === 'boolean') return v
- return toBoolean(v)
+ return validator.toBoolean('' + v)
}
function toValueOrNull (value: string) {
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 9ab1ef2343..e92ef9b925 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -98,15 +98,11 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } |
}
function isVideoPrivacyValid (value: number) {
- return validator.isInt(value + '') && VIDEO_PRIVACIES[ value ] !== undefined
+ return VIDEO_PRIVACIES[ value ] !== undefined
}
function isScheduleVideoUpdatePrivacyValid (value: number) {
- return validator.isInt(value + '') &&
- (
- value === VideoPrivacy.UNLISTED ||
- value === VideoPrivacy.PUBLIC
- )
+ return value === VideoPrivacy.UNLISTED || value === VideoPrivacy.PUBLIC
}
function isVideoOriginallyPublishedAtValid (value: string | null) {
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index db03dc2316..da92c715d4 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -2,7 +2,7 @@ import * as Bluebird from 'bluebird'
import * as express from 'express'
import { body, param } from 'express-validator'
import { omit } from 'lodash'
-import { isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
+import { isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
import {
isUserAdminFlagsValid,
isUserAutoPlayVideoValid,
@@ -357,7 +357,7 @@ const usersVerifyEmailValidator = [
.not().isEmpty().withMessage('Should have a valid verification string'),
body('isPendingEmail')
.optional()
- .customSanitizer(toIntOrNull),
+ .customSanitizer(toBooleanOrNull),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 27dfe91ca9..af06f3c629 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -349,7 +349,7 @@ function getCommonVideoEditAttributes () {
.custom(isDateValid).withMessage('Should have a valid schedule update date'),
body('scheduleUpdate.privacy')
.optional()
- .customSanitizer(toValueOrNull)
+ .customSanitizer(toIntOrNull)
.custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy')
] as (ValidationChain | express.Handler)[]
}