diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-31 15:09:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-31 15:09:34 +0200 |
commit | cf7a61b5a2b68fd966c4a355e37e84b048ed296b (patch) | |
tree | 4f4867344fe6856cb4f6b18856867c6e34171ea2 /server/middlewares/validators/avatar.ts | |
parent | c487d3033cad9c5e0f85ae49ed3d2a7b6c2711d8 (diff) | |
download | PeerTube-cf7a61b5a2b68fd966c4a355e37e84b048ed296b.tar.gz PeerTube-cf7a61b5a2b68fd966c4a355e37e84b048ed296b.tar.zst PeerTube-cf7a61b5a2b68fd966c4a355e37e84b048ed296b.zip |
Cleanup req files on bad request
Diffstat (limited to 'server/middlewares/validators/avatar.ts')
-rw-r--r-- | server/middlewares/validators/avatar.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/server/middlewares/validators/avatar.ts b/server/middlewares/validators/avatar.ts index f346ea92f..5860735c6 100644 --- a/server/middlewares/validators/avatar.ts +++ b/server/middlewares/validators/avatar.ts | |||
@@ -4,6 +4,7 @@ import { isAvatarFile } from '../../helpers/custom-validators/users' | |||
4 | import { areValidationErrors } from './utils' | 4 | import { areValidationErrors } from './utils' |
5 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 5 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import { cleanUpReqFiles } from '../../helpers/utils' | ||
7 | 8 | ||
8 | const updateAvatarValidator = [ | 9 | const updateAvatarValidator = [ |
9 | body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage( | 10 | body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage( |
@@ -14,7 +15,7 @@ const updateAvatarValidator = [ | |||
14 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 15 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
15 | logger.debug('Checking updateAvatarValidator parameters', { files: req.files }) | 16 | logger.debug('Checking updateAvatarValidator parameters', { files: req.files }) |
16 | 17 | ||
17 | if (areValidationErrors(req, res)) return | 18 | if (areValidationErrors(req, res)) return cleanUpReqFiles(req) |
18 | 19 | ||
19 | return next() | 20 | return next() |
20 | } | 21 | } |