if (err) {
return res.status(err.status)
.json({
- error: 'Authentication failed.',
+ error: 'Token is invalid.',
code: err.name
})
.end()
}
function token (req: express.Request, res: express.Response, next: express.NextFunction) {
- return oAuthServer.token()(req, res, next)
+ return oAuthServer.token()(req, res, err => {
+ if (err) {
+ return res.status(err.status)
+ .json({
+ error: 'Authentication failed.',
+ code: err.name
+ })
+ .end()
+ }
+
+ return next()
+ })
}
// ---------------------------------------------------------------------------
expect(res.body.error)
.to
- .equal('invalid_client')
+ .equal('Authentication failed.')
})
it('Should not login with an invalid client secret', async function () {
expect(res.body.error)
.to
- .equal('invalid_client')
+ .equal('Authentication failed.')
})
it('Should not login with an invalid username', async function () {
expect(res.body.error)
.to
- .equal('invalid_grant')
+ .equal('Authentication failed.')
})
it('Should not login with an invalid password', async function () {
expect(res.body.error)
.to
- .equal('invalid_grant')
+ .equal('Authentication failed.')
})
it('Should not be able to upload a video', async function () {