aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares/accounts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/middlewares/accounts.ts')
-rw-r--r--server/helpers/middlewares/accounts.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/helpers/middlewares/accounts.ts b/server/helpers/middlewares/accounts.ts
index e9b981262..23470cac6 100644
--- a/server/helpers/middlewares/accounts.ts
+++ b/server/helpers/middlewares/accounts.ts
@@ -3,6 +3,7 @@ import { AccountModel } from '../../models/account/account'
3import * as Bluebird from 'bluebird' 3import * as Bluebird from 'bluebird'
4import { MAccountDefault } from '../../types/models' 4import { MAccountDefault } from '../../types/models'
5import { UserModel } from '@server/models/account/user' 5import { UserModel } from '@server/models/account/user'
6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
6 7
7function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { 8function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
8 const promise = AccountModel.load(parseInt(id + '', 10)) 9 const promise = AccountModel.load(parseInt(id + '', 10))
@@ -27,7 +28,7 @@ async function doesAccountExist (p: Bluebird<MAccountDefault>, res: Response, se
27 28
28 if (!account) { 29 if (!account) {
29 if (sendNotFound === true) { 30 if (sendNotFound === true) {
30 res.status(404) 31 res.status(HttpStatusCode.NOT_FOUND_404)
31 .json({ error: 'Account not found' }) 32 .json({ error: 'Account not found' })
32 } 33 }
33 34
@@ -43,7 +44,7 @@ async function doesUserFeedTokenCorrespond (id: number, token: string, res: Resp
43 const user = await UserModel.loadByIdWithChannels(parseInt(id + '', 10)) 44 const user = await UserModel.loadByIdWithChannels(parseInt(id + '', 10))
44 45
45 if (token !== user.feedToken) { 46 if (token !== user.feedToken) {
46 res.status(403) 47 res.status(HttpStatusCode.FORBIDDEN_403)
47 .json({ error: 'User and token mismatch' }) 48 .json({ error: 'User and token mismatch' })
48 49
49 return false 50 return false