From 76148b27f7501bac061992136852be4303370c8d Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 1 Jun 2021 01:36:53 +0200 Subject: refactor API errors to standard error format --- server/middlewares/user-right.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'server/middlewares/user-right.ts') diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts index 45dda4781..d1888c2d3 100644 --- a/server/middlewares/user-right.ts +++ b/server/middlewares/user-right.ts @@ -10,8 +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(HttpStatusCode.FORBIDDEN_403) - .json({ error: message }) + return res.fail({ + status: HttpStatusCode.FORBIDDEN_403, + message + }) } return next() -- cgit v1.2.3