X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fmiddlewares%2Foauth.ts;h=e59168ea81fbec737a7da1ecb0aca601740186ad;hb=da854ddd502cd70685ef779c673b9e63757b8aa0;hp=468e418106c69c84ceb596b705665ebadfd7de40;hpb=4d4e5cd4dca78480ec7f40e747f424cd107376a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 468e41810..e59168ea8 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts @@ -1,7 +1,8 @@ +import 'express-validator' +import * as express from 'express' import * as OAuthServer from 'express-oauth-server' - +import { logger } from '../helpers/logger' import { OAUTH_LIFETIME } from '../initializers' -import { logger } from '../helpers' const oAuthServer = new OAuthServer({ accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN, @@ -9,10 +10,10 @@ const oAuthServer = new OAuthServer({ model: require('../lib/oauth-model') }) -function authenticate (req, res, next) { - oAuthServer.authenticate()(req, res, function (err) { +function authenticate (req: express.Request, res: express.Response, next: express.NextFunction) { + oAuthServer.authenticate()(req, res, err => { if (err) { - logger.error('Cannot authenticate.', { error: err }) + logger.error('Cannot authenticate.', err) return res.sendStatus(500) } @@ -22,7 +23,7 @@ function authenticate (req, res, next) { }) } -function token (req, res, next) { +function token (req: express.Request, res: express.Response, next: express.NextFunction) { return oAuthServer.token()(req, res, next) }