Update backend/src/graphql/directive/isAuthorized.ts

Co-authored-by: Ulf Gebhardt <ulf.gebhardt@webcraft-media.de>
This commit is contained in:
Moriz Wahl 2022-03-14 16:27:36 +01:00 committed by GitHub
parent fe38cec4ac
commit e7b104c3b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,7 @@ const isAuthorized: AuthChecker<any> = 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')
}