From 2d53be0267acc49cda46707b885096193a1f4e9c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 7 Dec 2020 14:32:36 +0100 Subject: replace numbers with typed http status codes (#3409) --- server/middlewares/user-right.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'server/middlewares/user-right.ts') diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts index aaf0b323a..45dda4781 100644 --- a/server/middlewares/user-right.ts +++ b/server/middlewares/user-right.ts @@ -1,6 +1,7 @@ import * as express from 'express' import { UserRight } from '../../shared' import { logger } from '../helpers/logger' +import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' function ensureUserHasRight (userRight: UserRight) { return function (req: express.Request, res: express.Response, next: express.NextFunction) { @@ -9,7 +10,8 @@ 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.status(HttpStatusCode.FORBIDDEN_403) + .json({ error: message }) } return next() -- cgit v1.2.3