diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 16:45:32 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 16:45:32 +0100 |
commit | 5960f92395e81cc851d4536325bee72ba930de3f (patch) | |
tree | 4ede6c7bd9a52090a8a429c7e6b008a72c27d4fa /server/middlewares/oauth.ts | |
parent | 11ba2ab3f1e3ec29b3765fa0c1ff4ed410c851a9 (diff) | |
download | PeerTube-5960f92395e81cc851d4536325bee72ba930de3f.tar.gz PeerTube-5960f92395e81cc851d4536325bee72ba930de3f.tar.zst PeerTube-5960f92395e81cc851d4536325bee72ba930de3f.zip |
Fix user tests
Diffstat (limited to 'server/middlewares/oauth.ts')
-rw-r--r-- | server/middlewares/oauth.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 9976993e0..41a3fb718 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts | |||
@@ -15,7 +15,7 @@ function authenticate (req: express.Request, res: express.Response, next: expres | |||
15 | if (err) { | 15 | if (err) { |
16 | return res.status(err.status) | 16 | return res.status(err.status) |
17 | .json({ | 17 | .json({ |
18 | error: 'Authentication failed.', | 18 | error: 'Token is invalid.', |
19 | code: err.name | 19 | code: err.name |
20 | }) | 20 | }) |
21 | .end() | 21 | .end() |
@@ -26,7 +26,18 @@ function authenticate (req: express.Request, res: express.Response, next: expres | |||
26 | } | 26 | } |
27 | 27 | ||
28 | function token (req: express.Request, res: express.Response, next: express.NextFunction) { | 28 | function token (req: express.Request, res: express.Response, next: express.NextFunction) { |
29 | return oAuthServer.token()(req, res, next) | 29 | return oAuthServer.token()(req, res, err => { |
30 | if (err) { | ||
31 | return res.status(err.status) | ||
32 | .json({ | ||
33 | error: 'Authentication failed.', | ||
34 | code: err.name | ||
35 | }) | ||
36 | .end() | ||
37 | } | ||
38 | |||
39 | return next() | ||
40 | }) | ||
30 | } | 41 | } |
31 | 42 | ||
32 | // --------------------------------------------------------------------------- | 43 | // --------------------------------------------------------------------------- |