aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/oauth.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/oauth.ts')
-rw-r--r--server/middlewares/oauth.ts3
1 files changed, 2 insertions, 1 deletions
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'
3import { oAuthServer } from '@server/lib/auth' 3import { oAuthServer } from '@server/lib/auth'
4import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
5import { getAccessToken } from '../lib/oauth-model' 5import { getAccessToken } from '../lib/oauth-model'
6import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
6 7
7function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) { 8function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) {
8 const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {} 9 const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {}
@@ -50,7 +51,7 @@ function authenticatePromiseIfNeeded (req: express.Request, res: express.Respons
50 // Already authenticated? (or tried to) 51 // Already authenticated? (or tried to)
51 if (res.locals.oauth?.token.User) return resolve() 52 if (res.locals.oauth?.token.User) return resolve()
52 53
53 if (res.locals.authenticated === false) return res.sendStatus(401) 54 if (res.locals.authenticated === false) return res.sendStatus(HttpStatusCode.UNAUTHORIZED_401)
54 55
55 authenticate(req, res, () => resolve(), authenticateInQuery) 56 authenticate(req, res, () => resolve(), authenticateInQuery)
56 }) 57 })