From: Chocobozzz Date: Wed, 11 Jan 2017 18:15:23 +0000 (+0100) Subject: Server: fix update right checks X-Git-Tag: v0.0.1-alpha~574^2~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=63d00f5ded0aad25eeb50111da65b6daa46bcb24;p=oweals%2Fpeertube.git Server: fix update right checks --- diff --git a/server/middlewares/validators/videos.js b/server/middlewares/validators/videos.js index 3d7c04b60..4fe6dcd8b 100644 --- a/server/middlewares/validators/videos.js +++ b/server/middlewares/validators/videos.js @@ -53,15 +53,18 @@ function videosUpdate (req, res, next) { logger.debug('Checking videosUpdate parameters', { parameters: req.body }) checkErrors(req, res, function () { - if (res.locals.video.isOwned() === false) { - return res.status(403).send('Cannot update video of another pod') - } + checkVideoExists(req.params.id, res, function () { + // We need to make additional checks + if (res.locals.video.isOwned() === false) { + return res.status(403).send('Cannot update video of another pod') + } - if (res.locals.video.Author.userId !== res.locals.oauth.token.User.id) { - return res.status(403).send('Cannot update video of another user') - } + if (res.locals.video.Author.userId !== res.locals.oauth.token.User.id) { + return res.status(403).send('Cannot update video of another user') + } - checkVideoExists(req.params.id, res, next) + next() + }) }) }