diff options
Diffstat (limited to 'server/middlewares')
-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 | // --------------------------------------------------------------------------- |