aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-02 15:43:44 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitaf4ae64f6faf38f8179f2e07d3cd4ad60006be92 (patch)
treea2d39ddc138d49619f03f11e003c2302f824286c /server/middlewares
parent77e9f859c6ad75ba179dec74e5410cc651eaa49b (diff)
downloadPeerTube-af4ae64f6faf38f8179f2e07d3cd4ad60006be92.tar.gz
PeerTube-af4ae64f6faf38f8179f2e07d3cd4ad60006be92.tar.zst
PeerTube-af4ae64f6faf38f8179f2e07d3cd4ad60006be92.zip
Begin live tests
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/videos/video-live.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index 69200cb60..cbc48fe93 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -16,14 +16,14 @@ const videoLiveGetValidator = [
16 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 16 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
17 17
18 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 18 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 logger.debug('Checking videoLiveGetValidator parameters', { parameters: req.body }) 19 logger.debug('Checking videoLiveGetValidator parameters', { parameters: req.params, user: res.locals.oauth.token.User.username })
20 20
21 if (areValidationErrors(req, res)) return 21 if (areValidationErrors(req, res)) return
22 if (!await doesVideoExist(req.params.videoId, res, 'all')) return 22 if (!await doesVideoExist(req.params.videoId, res, 'all')) return
23 23
24 // Check if the user who did the request is able to update the video 24 // Check if the user who did the request is able to get the live info
25 const user = res.locals.oauth.token.User 25 const user = res.locals.oauth.token.User
26 if (!checkUserCanManageVideo(user, res.locals.videoAll, UserRight.UPDATE_ANY_VIDEO, res)) return 26 if (!checkUserCanManageVideo(user, res.locals.videoAll, UserRight.GET_ANY_LIVE, res, false)) return
27 27
28 const videoLive = await VideoLiveModel.loadByVideoId(res.locals.videoAll.id) 28 const videoLive = await VideoLiveModel.loadByVideoId(res.locals.videoAll.id)
29 if (!videoLive) return res.sendStatus(404) 29 if (!videoLive) return res.sendStatus(404)
@@ -122,6 +122,10 @@ const videoLiveUpdateValidator = [
122 .json({ error: 'Cannot update a live that has already started' }) 122 .json({ error: 'Cannot update a live that has already started' })
123 } 123 }
124 124
125 // Check the user can manage the live
126 const user = res.locals.oauth.token.User
127 if (!checkUserCanManageVideo(user, res.locals.videoAll, UserRight.GET_ANY_LIVE, res)) return
128
125 return next() 129 return next()
126 } 130 }
127] 131]