From 14f9d8b0e58549e37ee0268bb8c5511eff1266ec Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 15 Oct 2020 20:23:19 -0400 Subject: [PATCH] feat: send back 403 on no-privileges error --- src/controllers/helpers.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 76dc5f6fa4..4f1a8c6d81 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -357,6 +357,13 @@ helpers.formatApiResponse = async (statusCode, res, payload) => { message = payload.message; } + // Update status code based on some common error codes + switch (payload.message) { + case '[[error:no-privileges]]': + statusCode = 403; + break; + } + const returnPayload = helpers.generateError(statusCode, message); if (global.env === 'development') {