X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fauth.ts;h=ad3b24ab21c27a1147aa3ca59ce8db56154f02c1;hb=2c2befaacaa7063df0d4557b71c187ee168a8eb6;hp=9e6327b2379ed2c018803fc7567e91380dca8694;hpb=c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts index 9e6327b23..ad3b24ab2 100644 --- a/server/middlewares/auth.ts +++ b/server/middlewares/auth.ts @@ -1,4 +1,4 @@ -import * as express from 'express' +import express from 'express' import { Socket } from 'socket.io' import { getAccessToken } from '@server/lib/auth/oauth-model' import { HttpStatusCode } from '../../shared/models/http/http-error-codes' @@ -47,7 +47,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) { .catch(err => logger.error('Cannot get access token.', { err })) } -function authenticatePromiseIfNeeded (req: express.Request, res: express.Response, authenticateInQuery = false) { +function authenticatePromise (req: express.Request, res: express.Response, authenticateInQuery = false) { return new Promise(resolve => { // Already authenticated? (or tried to) if (res.locals.oauth?.token.User) return resolve() @@ -76,6 +76,6 @@ function optionalAuthenticate (req: express.Request, res: express.Response, next export { authenticate, authenticateSocket, - authenticatePromiseIfNeeded, + authenticatePromise, optionalAuthenticate }