]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/user-right.ts
Prevent caption listing of private videos
[github/Chocobozzz/PeerTube.git] / server / middlewares / user-right.ts
index aaf0b323a035e8c12a055af23bfa8812f229f5eb..ea95b16c2d8550f9cb6fc30636bb3b9b2d94af4e 100644 (file)
@@ -1,5 +1,6 @@
-import * as express from 'express'
+import express from 'express'
 import { UserRight } from '../../shared'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
 import { logger } from '../helpers/logger'
 
 function ensureUserHasRight (userRight: UserRight) {
@@ -9,7 +10,10 @@ function ensureUserHasRight (userRight: UserRight) {
       const message = `User ${user.username} does not have right ${userRight} to access to ${req.path}.`
       logger.info(message)
 
-      return res.status(403).json({ error: message })
+      return res.fail({
+        status: HttpStatusCode.FORBIDDEN_403,
+        message
+      })
     }
 
     return next()