]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/user-right.ts
Improve views/viewers documentation
[github/Chocobozzz/PeerTube.git] / server / middlewares / user-right.ts
index aaf0b323a035e8c12a055af23bfa8812f229f5eb..7d53e834125aeaa12226d6a055c5675a27a59cac 100644 (file)
@@ -1,5 +1,5 @@
-import * as express from 'express'
-import { UserRight } from '../../shared'
+import express from 'express'
+import { HttpStatusCode, UserRight } from '@shared/models'
 import { logger } from '../helpers/logger'
 
 function ensureUserHasRight (userRight: UserRight) {
@@ -9,7 +9,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()