aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-03 10:41:23 +0100
committerChocobozzz <me@florianbigard.com>2019-12-03 10:41:23 +0100
commiteccf70f020cb8b0d9ceddc2561713ccfddb72095 (patch)
treebae9d9285a00c2958666becbb50427cabcea7aed /server/middlewares/validators/videos
parent3f6b7aa1cfa28ee02eec8c8ab16b623f2bbab928 (diff)
downloadPeerTube-eccf70f020cb8b0d9ceddc2561713ccfddb72095.tar.gz
PeerTube-eccf70f020cb8b0d9ceddc2561713ccfddb72095.tar.zst
PeerTube-eccf70f020cb8b0d9ceddc2561713ccfddb72095.zip
Fix private video download
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/videos.ts6
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
150const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video-with-rights') => { 150const 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
195const videosGetValidator = videosCustomGetValidator('all') 195const videosGetValidator = videosCustomGetValidator('all')
196const videosDownloadValidator = videosCustomGetValidator('all', true)
196 197
197const videosRemoveValidator = [ 198const 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,