From e7b104c3b5a1ca561967f6c28acbe0fb6fc1fa6c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 14 Mar 2022 16:27:36 +0100 Subject: [PATCH] Update backend/src/graphql/directive/isAuthorized.ts Co-authored-by: Ulf Gebhardt --- backend/src/graphql/directive/isAuthorized.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 9a60fb10d..159a1614c 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -38,6 +38,7 @@ const isAuthorized: AuthChecker = async ({ context }, rights) => { const countServerUsers = await ServerUser.count({ email: user.email }) context.role = countServerUsers > 0 ? ROLE_ADMIN : ROLE_USER } catch { + // in case the database query fails (user deleted) throw new Error('401 Unauthorized') }