diff options
Diffstat (limited to 'server/middlewares/validators/users.js')
-rw-r--r-- | server/middlewares/validators/users.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/server/middlewares/validators/users.js b/server/middlewares/validators/users.js index 3089370ff..ce83fc074 100644 --- a/server/middlewares/validators/users.js +++ b/server/middlewares/validators/users.js | |||
@@ -7,7 +7,8 @@ const logger = require('../../helpers/logger') | |||
7 | const validatorsUsers = { | 7 | const validatorsUsers = { |
8 | usersAdd, | 8 | usersAdd, |
9 | usersRemove, | 9 | usersRemove, |
10 | usersUpdate | 10 | usersUpdate, |
11 | usersVideoRating | ||
11 | } | 12 | } |
12 | 13 | ||
13 | function usersAdd (req, res, next) { | 14 | function usersAdd (req, res, next) { |
@@ -62,6 +63,25 @@ function usersUpdate (req, res, next) { | |||
62 | checkErrors(req, res, next) | 63 | checkErrors(req, res, next) |
63 | } | 64 | } |
64 | 65 | ||
66 | function usersVideoRating (req, res, next) { | ||
67 | req.checkParams('videoId', 'Should have a valid video id').notEmpty().isUUID(4) | ||
68 | |||
69 | logger.debug('Checking usersVideoRating parameters', { parameters: req.params }) | ||
70 | |||
71 | checkErrors(req, res, function () { | ||
72 | db.Video.load(req.params.videoId, function (err, video) { | ||
73 | if (err) { | ||
74 | logger.error('Error in user request validator.', { error: err }) | ||
75 | return res.sendStatus(500) | ||
76 | } | ||
77 | |||
78 | if (!video) return res.status(404).send('Video not found') | ||
79 | |||
80 | next() | ||
81 | }) | ||
82 | }) | ||
83 | } | ||
84 | |||
65 | // --------------------------------------------------------------------------- | 85 | // --------------------------------------------------------------------------- |
66 | 86 | ||
67 | module.exports = validatorsUsers | 87 | module.exports = validatorsUsers |