]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/oauth.ts
Propagate old comment on new follow
[github/Chocobozzz/PeerTube.git] / server / middlewares / oauth.ts
index 468e418106c69c84ceb596b705665ebadfd7de40..e59168ea81fbec737a7da1ecb0aca601740186ad 100644 (file)
@@ -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)
 }