X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fauth.ts;h=ad3b24ab21c27a1147aa3ca59ce8db56154f02c1;hb=2c2befaacaa7063df0d4557b71c187ee168a8eb6;hp=176461cc2cae41fb09aff44472adbb23080c2db7;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts index 176461cc2..ad3b24ab2 100644 --- a/server/middlewares/auth.ts +++ b/server/middlewares/auth.ts @@ -1,7 +1,7 @@ -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/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../shared/models/http/http-error-codes' import { logger } from '../helpers/logger' import { handleOAuthAuthenticate } from '../lib/auth/oauth' @@ -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 }