diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-03 10:41:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-03 10:41:23 +0100 |
commit | eccf70f020cb8b0d9ceddc2561713ccfddb72095 (patch) | |
tree | bae9d9285a00c2958666becbb50427cabcea7aed /server/middlewares/validators | |
parent | 3f6b7aa1cfa28ee02eec8c8ab16b623f2bbab928 (diff) | |
download | PeerTube-eccf70f020cb8b0d9ceddc2561713ccfddb72095.tar.gz PeerTube-eccf70f020cb8b0d9ceddc2561713ccfddb72095.tar.zst PeerTube-eccf70f020cb8b0d9ceddc2561713ccfddb72095.zip |
Fix private video download
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 53a2f193d..ab984d84a 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -147,7 +147,7 @@ async function checkVideoFollowConstraints (req: express.Request, res: express.R | |||
147 | }) | 147 | }) |
148 | } | 148 | } |
149 | 149 | ||
150 | const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video-with-rights') => { | 150 | const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video-with-rights', authenticateInQuery = false) => { |
151 | return [ | 151 | return [ |
152 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), | 152 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), |
153 | 153 | ||
@@ -162,7 +162,7 @@ const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video- | |||
162 | 162 | ||
163 | // Video private or blacklisted | 163 | // Video private or blacklisted |
164 | if (video.privacy === VideoPrivacy.PRIVATE || videoAll.VideoBlacklist) { | 164 | if (video.privacy === VideoPrivacy.PRIVATE || videoAll.VideoBlacklist) { |
165 | await authenticatePromiseIfNeeded(req, res) | 165 | await authenticatePromiseIfNeeded(req, res, authenticateInQuery) |
166 | 166 | ||
167 | const user = res.locals.oauth ? res.locals.oauth.token.User : null | 167 | const user = res.locals.oauth ? res.locals.oauth.token.User : null |
168 | 168 | ||
@@ -193,6 +193,7 @@ const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video- | |||
193 | } | 193 | } |
194 | 194 | ||
195 | const videosGetValidator = videosCustomGetValidator('all') | 195 | const videosGetValidator = videosCustomGetValidator('all') |
196 | const videosDownloadValidator = videosCustomGetValidator('all', true) | ||
196 | 197 | ||
197 | const videosRemoveValidator = [ | 198 | const videosRemoveValidator = [ |
198 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), | 199 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), |
@@ -407,6 +408,7 @@ export { | |||
407 | videosAddValidator, | 408 | videosAddValidator, |
408 | videosUpdateValidator, | 409 | videosUpdateValidator, |
409 | videosGetValidator, | 410 | videosGetValidator, |
411 | videosDownloadValidator, | ||
410 | checkVideoFollowConstraints, | 412 | checkVideoFollowConstraints, |
411 | videosCustomGetValidator, | 413 | videosCustomGetValidator, |
412 | videosRemoveValidator, | 414 | videosRemoveValidator, |