diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 86c56312f..0642be630 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,10 +1,12 @@ import { ObjectType, Field } from 'type-graphql' import { KlickTipp } from './KlickTipp' import { User as dbUser } from '@entity/User' +import Decimal from 'decimal.js-light' +import { FULL_CREATION_AVAILABLE } from '../resolver/const/const' @ObjectType() export class User { - constructor(user: dbUser) { + constructor(user: dbUser, creation: Decimal[] = FULL_CREATION_AVAILABLE) { this.id = user.id this.email = user.email this.firstName = user.firstName @@ -17,6 +19,7 @@ export class User { this.isAdmin = user.isAdmin this.klickTipp = null this.hasElopage = null + this.creation = creation } @Field(() => Number) @@ -64,4 +67,7 @@ export class User { @Field(() => Boolean, { nullable: true }) hasElopage: boolean | null + + @Field(() => [Decimal]) + creation: Decimal[] } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 0bde22ae6..5b824b38f 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -23,6 +23,7 @@ import { sendAccountMultiRegistrationEmail } from '@/mailer/sendAccountMultiRegi import { klicktippSignIn } from '@/apis/KlicktippController' import { RIGHTS } from '@/auth/RIGHTS' import { hasElopageBuys } from '@/util/hasElopageBuys' +import { getUserCreation } from './util/creations' // eslint-disable-next-line @typescript-eslint/no-var-requires const sodium = require('sodium-native') @@ -224,7 +225,7 @@ export class UserResolver { logger.info('verifyLogin...') // TODO refactor and do not have duplicate code with login(see below) const userEntity = getUser(context) - const user = new User(userEntity) + const user = new User(userEntity, await getUserCreation(userEntity.id)) // user.pubkey = userEntity.pubKey.toString('hex') // Elopage Status & Stored PublisherId user.hasElopage = await this.hasElopage(context) @@ -274,7 +275,7 @@ export class UserResolver { logger.addContext('user', dbUser.id) logger.debug('login credentials valid...') - const user = new User(dbUser) + const user = new User(dbUser, await getUserCreation(dbUser.id)) logger.debug('user=' + user) // Elopage Status & Stored PublisherId