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/helpers/middlewares/accounts.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/middlewares/accounts.ts b/server/helpers/middlewares/accounts.ts index 9be80167c..fa4a51e6c 100644 --- a/server/helpers/middlewares/accounts.ts +++ b/server/helpers/middlewares/accounts.ts @@ -28,8 +28,7 @@ async function doesAccountExist (p: Bluebird, res: Response, se if (!account) { if (sendNotFound === true) { res.status(404) - .send({ error: 'Account not found' }) - .end() + .json({ error: 'Account not found' }) } return false @@ -41,12 +40,11 @@ async function doesAccountExist (p: Bluebird, res: Response, se } async function doesUserFeedTokenCorrespond (id: number | string, token: string, res: Response) { - const user = await UserModel.loadById(parseInt(id + '', 10)) + const user = await UserModel.loadByIdWithChannels(parseInt(id + '', 10)) if (token !== user.feedToken) { res.status(401) - .send({ error: 'User and token mismatch' }) - .end() + .json({ error: 'User and token mismatch' }) return false } -- cgit v1.2.3