X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Foauth.ts;h=b1149174bfbf633c0ba7314718b997fa8f9ab451;hb=68e70a745b2010cd0199864a2addd60d8f99c732;hp=4ae7f18c2002e1182964c0c04fde29cfd5635cee;hpb=7fed637506043e4432cbebe041ada0625171cceb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 4ae7f18c2..b1149174b 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { logger } from '../helpers/logger' import { Socket } from 'socket.io' import { getAccessToken } from '../lib/oauth-model' -import { handleIdAndPassLogin, oAuthServer } from '@server/lib/auth' +import { oAuthServer } from '@server/lib/auth' function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) { const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {} @@ -48,7 +48,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) { function authenticatePromiseIfNeeded (req: express.Request, res: express.Response, authenticateInQuery = false) { return new Promise(resolve => { // Already authenticated? (or tried to) - if (res.locals.oauth && res.locals.oauth.token.User) return resolve() + if (res.locals.oauth?.token.User) return resolve() if (res.locals.authenticated === false) return res.sendStatus(401)