aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-08-13 15:07:23 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 11:07:56 +0100
commitafff310e50f2fa8419bb4242470cbde46ab54463 (patch)
tree34efda2daf8f7cdfd89ef6616a79e2222082f93a /server/middlewares/validators
parentf619de0e435f7ac3abad2ec772397486358b56e7 (diff)
downloadPeerTube-afff310e50f2fa8419bb4242470cbde46ab54463.tar.gz
PeerTube-afff310e50f2fa8419bb4242470cbde46ab54463.tar.zst
PeerTube-afff310e50f2fa8419bb4242470cbde46ab54463.zip
allow private syndication feeds via a user feedToken
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/feeds.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index c3de0f5fe..5c76a679f 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -9,7 +9,8 @@ import {
9 doesAccountIdExist, 9 doesAccountIdExist,
10 doesAccountNameWithHostExist, 10 doesAccountNameWithHostExist,
11 doesVideoChannelIdExist, 11 doesVideoChannelIdExist,
12 doesVideoChannelNameWithHostExist 12 doesVideoChannelNameWithHostExist,
13 doesUserFeedTokenCorrespond
13} from '../../helpers/middlewares' 14} from '../../helpers/middlewares'
14 15
15const feedsFormatValidator = [ 16const feedsFormatValidator = [
@@ -62,6 +63,23 @@ const videoFeedsValidator = [
62 } 63 }
63] 64]
64 65
66const videoSubscriptonFeedsValidator = [
67 query('accountId').optional().custom(isIdValid),
68 query('token').optional(),
69
70 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
71 logger.debug('Checking feeds parameters', { parameters: req.query })
72
73 if (areValidationErrors(req, res)) return
74
75 // a token alone is erroneous
76 if (req.query.token && !req.query.accountId) return
77 if (req.query.token && !await doesUserFeedTokenCorrespond(res.locals.account.userId, req.query.token, res)) return
78
79 return next()
80 }
81]
82
65const videoCommentsFeedsValidator = [ 83const videoCommentsFeedsValidator = [
66 query('videoId').optional().custom(isIdOrUUIDValid), 84 query('videoId').optional().custom(isIdOrUUIDValid),
67 85
@@ -88,5 +106,6 @@ export {
88 feedsFormatValidator, 106 feedsFormatValidator,
89 setFeedFormatContentType, 107 setFeedFormatContentType,
90 videoFeedsValidator, 108 videoFeedsValidator,
109 videoSubscriptonFeedsValidator,
91 videoCommentsFeedsValidator 110 videoCommentsFeedsValidator
92} 111}