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') }