From 2aa95b452634fa86ce6d0f171a8e7923fe83407f Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 29 Jan 2023 14:42:47 +0100 Subject: [PATCH] added custom error handling --- backend/src/middlewares/auth.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/middlewares/auth.ts b/backend/src/middlewares/auth.ts index 290a2421c..c862344af 100644 --- a/backend/src/middlewares/auth.ts +++ b/backend/src/middlewares/auth.ts @@ -184,6 +184,12 @@ async function authenticateWithBearerToken( "Token revoked. Please login again.", "authenticateWithBearerToken" ); + } else if (errorCode?.includes("auth/user-not-found")) { + throw new MonkeyError( + 401, + "User not found.", + "authenticateWithBearerToken" + ); } else { throw error; }