diff --git a/backend/src/middlewares/auth.ts b/backend/src/middlewares/auth.ts index c862344af..d833413c8 100644 --- a/backend/src/middlewares/auth.ts +++ b/backend/src/middlewares/auth.ts @@ -186,10 +186,16 @@ async function authenticateWithBearerToken( ); } else if (errorCode?.includes("auth/user-not-found")) { throw new MonkeyError( - 401, + 404, "User not found.", "authenticateWithBearerToken" ); + } else if (errorCode?.includes("auth/argument-error")) { + throw new MonkeyError( + 400, + "Incorrect Bearer token format.", + "authenticateWithBearerToken" + ); } else { throw error; }