Improve check follow params tests
[oweals/peertube.git] / server / middlewares / oauth.ts
index e59168ea81fbec737a7da1ecb0aca601740186ad..12872c4a5a2776bc16560e6678d0b8cacc0ccb76 100644 (file)
@@ -17,7 +17,11 @@ function authenticate (req: express.Request, res: express.Response, next: expres
       return res.sendStatus(500)
     }
 
-    if (res.statusCode === 401 || res.statusCode === 400 || res.statusCode === 503) return res.end()
+    if (res.statusCode === 401 || res.statusCode === 400 || res.statusCode === 503) {
+      return res.json({
+        error: 'Authentication failed.'
+      }).end()
+    }
 
     return next()
   })