From 2d53be0267acc49cda46707b885096193a1f4e9c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 7 Dec 2020 14:32:36 +0100 Subject: replace numbers with typed http status codes (#3409) --- server/middlewares/oauth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server/middlewares/oauth.ts') diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index bd60a3639..ab5301415 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts @@ -3,6 +3,7 @@ import { Socket } from 'socket.io' import { oAuthServer } from '@server/lib/auth' import { logger } from '../helpers/logger' import { getAccessToken } from '../lib/oauth-model' +import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) { const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {} @@ -50,7 +51,7 @@ function authenticatePromiseIfNeeded (req: express.Request, res: express.Respons // Already authenticated? (or tried to) if (res.locals.oauth?.token.User) return resolve() - if (res.locals.authenticated === false) return res.sendStatus(401) + if (res.locals.authenticated === false) return res.sendStatus(HttpStatusCode.UNAUTHORIZED_401) authenticate(req, res, () => resolve(), authenticateInQuery) }) -- cgit v1.2.3