From 5beb89f223539f1e415a976ff104f772526b4d20 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 9 Nov 2020 16:25:27 +0100 Subject: refactor scoped token service --- server/middlewares/validators/feeds.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'server/middlewares/validators/feeds.ts') diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index 5c76a679f..35080ffca 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts @@ -64,8 +64,8 @@ const videoFeedsValidator = [ ] const videoSubscriptonFeedsValidator = [ - query('accountId').optional().custom(isIdValid), - query('token').optional(), + query('accountId').custom(isIdValid), + query('token'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking feeds parameters', { parameters: req.query }) @@ -74,6 +74,7 @@ const videoSubscriptonFeedsValidator = [ // a token alone is erroneous if (req.query.token && !req.query.accountId) return + if (req.query.accountId && !await doesAccountIdExist(req.query.accountId, res)) return if (req.query.token && !await doesUserFeedTokenCorrespond(res.locals.account.userId, req.query.token, res)) return return next() -- cgit v1.2.3