aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 14:40:11 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 14:40:11 +0100
commit93e4a311f37d7fc82ec81190553f8beae28fdef5 (patch)
treebced0a69b51d0bab35b01bfede629eef60ce3675 /server/middlewares
parenteec63bbc0f4fdb39e56f37127b35c449f90a135f (diff)
downloadPeerTube-93e4a311f37d7fc82ec81190553f8beae28fdef5.tar.gz
PeerTube-93e4a311f37d7fc82ec81190553f8beae28fdef5.tar.zst
PeerTube-93e4a311f37d7fc82ec81190553f8beae28fdef5.zip
Improve check jobs parameters tests
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/oauth.ts18
1 files changed, 8 insertions, 10 deletions
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts
index 12872c4a5..9976993e0 100644
--- a/server/middlewares/oauth.ts
+++ b/server/middlewares/oauth.ts
@@ -1,10 +1,10 @@
1import 'express-validator'
2import * as express from 'express' 1import * as express from 'express'
3import * as OAuthServer from 'express-oauth-server' 2import * as OAuthServer from 'express-oauth-server'
4import { logger } from '../helpers/logger' 3import 'express-validator'
5import { OAUTH_LIFETIME } from '../initializers' 4import { OAUTH_LIFETIME } from '../initializers'
6 5
7const oAuthServer = new OAuthServer({ 6const oAuthServer = new OAuthServer({
7 useErrorHandler: true,
8 accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN, 8 accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN,
9 refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN, 9 refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN,
10 model: require('../lib/oauth-model') 10 model: require('../lib/oauth-model')
@@ -13,14 +13,12 @@ const oAuthServer = new OAuthServer({
13function authenticate (req: express.Request, res: express.Response, next: express.NextFunction) { 13function authenticate (req: express.Request, res: express.Response, next: express.NextFunction) {
14 oAuthServer.authenticate()(req, res, err => { 14 oAuthServer.authenticate()(req, res, err => {
15 if (err) { 15 if (err) {
16 logger.error('Cannot authenticate.', err) 16 return res.status(err.status)
17 return res.sendStatus(500) 17 .json({
18 } 18 error: 'Authentication failed.',
19 19 code: err.name
20 if (res.statusCode === 401 || res.statusCode === 400 || res.statusCode === 503) { 20 })
21 return res.json({ 21 .end()
22 error: 'Authentication failed.'
23 }).end()
24 } 22 }
25 23
26 return next() 24 return next()