From 35eef52aef77ec653ab9eab642d35240732aed07 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Tue, 27 Jun 2023 02:39:01 +0200 Subject: [PATCH] add "isModerator" in graphql model --- backend/src/graphql/model/User.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 496f263d9..3558a0840 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,3 +1,4 @@ +import { ROLE_NAMES } from '@/auth/ROLES' import { User as dbUser } from '@entity/User' import { ObjectType, Field, Int } from 'type-graphql' @@ -19,7 +20,17 @@ export class User { this.language = user.language this.publisherId = user.publisherId if (user.userRole) { - this.isAdmin = user.userRole.createdAt + switch (user.userRole.role) { + case ROLE_NAMES.ROLE_NAME_ADMIN: + this.isAdmin = user.userRole.createdAt + break + case ROLE_NAMES.ROLE_NAME_MODERATOR: + this.isModerator = user.userRole.createdAt + break + default: + this.isAdmin = null + this.isModerator = null + } } this.klickTipp = null this.hasElopage = null @@ -67,6 +78,9 @@ export class User { @Field(() => Date, { nullable: true }) isAdmin: Date | null + @Field(() => Date, { nullable: true }) + isModerator: Date | null + @Field(() => KlickTipp, { nullable: true }) klickTipp: KlickTipp | null