aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares/accounts.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/helpers/middlewares/accounts.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
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