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

good hint, many thx...

Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de>
This commit is contained in:
clauspeterhuebner 2023-07-12 22:53:38 +02:00 committed by GitHub
parent 928091029a
commit 47bf651ba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ export const isAuthorized: AuthChecker<Context> = async ({ context }, rights) =>
})
context.user = user
context.role = ROLE_USER
if (user.userRoles && user.userRoles.length > 0) {
if (user.userRoles?.length > 0) {
switch (user.userRoles[0].role) {
case ROLE_NAMES.ROLE_NAME_ADMIN:
context.role = ROLE_ADMIN