diff --git a/backend/src/graphql/arg/CreateUserArgs.ts b/backend/src/graphql/arg/CreateUserArgs.ts index 486cb023b..3d09e56eb 100644 --- a/backend/src/graphql/arg/CreateUserArgs.ts +++ b/backend/src/graphql/arg/CreateUserArgs.ts @@ -1,4 +1,4 @@ -import { ArgsType, Field } from 'type-graphql' +import { ArgsType, Field, Int } from 'type-graphql' @ArgsType() export default class CreateUserArgs { @@ -16,4 +16,7 @@ export default class CreateUserArgs { @Field(() => String) language: string + + @Field(() => Int, { nullable: true }) + publisherId: number } diff --git a/backend/src/graphql/arg/UnsecureLoginArgs.ts b/backend/src/graphql/arg/UnsecureLoginArgs.ts index 42e467eee..ac69e7441 100644 --- a/backend/src/graphql/arg/UnsecureLoginArgs.ts +++ b/backend/src/graphql/arg/UnsecureLoginArgs.ts @@ -1,4 +1,4 @@ -import { ArgsType, Field } from 'type-graphql' +import { ArgsType, Field, Int } from 'type-graphql' @ArgsType() export default class UnsecureLoginArgs { @@ -8,6 +8,6 @@ export default class UnsecureLoginArgs { @Field(() => String) password: string - @Field(() => Number, { nullable: true }) + @Field(() => Int, { nullable: true }) publisherId: number } diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 890e8bdba..08651ae17 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { ObjectType, Field } from 'type-graphql' +import { ObjectType, Field, Int } from 'type-graphql' import { KlickTipp } from './KlickTipp' @ObjectType() @@ -66,8 +66,8 @@ export class User { groupId: number */ // what is publisherId? - @Field(() => Number) - publisherId: number + @Field(() => Int, { nullable: true }) + publisherId?: number @Field(() => Boolean) coinanimation: boolean diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 1f5667e8f..2dcffb2d9 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -48,6 +48,9 @@ export class UserResolver { value: encode(result.data.session_id, result.data.user.public_hex), }) const user = new User(result.data.user) + if (user.publisherId === 0) { + user.publisherId = undefined + } user.hasElopage = result.data.hasElopage // read additional settings from settings table const userRepository = getCustomRepository(UserRepository) @@ -68,8 +71,7 @@ export class UserResolver { throw new Error('error with cannot happen') } - if (publisherId) { - // Save it + if (!user.hasElopage && publisherId) { user.publisherId = publisherId await this.updateUserInfos( { publisherId }, @@ -115,7 +117,7 @@ export class UserResolver { @Mutation(() => String) async createUser( - @Args() { email, firstName, lastName, password, language }: CreateUserArgs, + @Args() { email, firstName, lastName, password, language, publisherId }: CreateUserArgs, ): Promise { const payload = { email, @@ -125,7 +127,7 @@ export class UserResolver { emailType: 2, login_after_register: true, language: language, - publisher_id: 0, + publisher_id: publisherId, } const result = await apiPost(CONFIG.LOGIN_API_URL + 'createUser', payload) if (!result.success) {