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

Cleanup req files on bad request

This commit is contained in:
Chocobozzz 2018-07-31 15:09:34 +02:00
parent c487d3033c
commit cf7a61b5a2
No known key found for this signature in database
GPG key ID: 583A612D890159BE
9 changed files with 50 additions and 22 deletions

View file

@ -4,6 +4,7 @@ import { isAvatarFile } from '../../helpers/custom-validators/users'
import { areValidationErrors } from './utils'
import { CONSTRAINTS_FIELDS } from '../../initializers'
import { logger } from '../../helpers/logger'
import { cleanUpReqFiles } from '../../helpers/utils'
const updateAvatarValidator = [
body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage(
@ -14,7 +15,7 @@ const updateAvatarValidator = [
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking updateAvatarValidator parameters', { files: req.files })
if (areValidationErrors(req, res)) return
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
return next()
}