mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Added the publisherId to the login & createUser calls, adjusted the tests to the new code.
This commit is contained in:
parent
5a14161284
commit
58182d73c6
@ -1,4 +1,4 @@
|
|||||||
import { ArgsType, Field } from 'type-graphql'
|
import { ArgsType, Field, Int } from 'type-graphql'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class CreateUserArgs {
|
export default class CreateUserArgs {
|
||||||
@ -16,4 +16,7 @@ export default class CreateUserArgs {
|
|||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
language: string
|
language: string
|
||||||
|
|
||||||
|
@Field(() => Int, { nullable: true })
|
||||||
|
publisherId: number
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ArgsType, Field } from 'type-graphql'
|
import { ArgsType, Field, Int } from 'type-graphql'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class UnsecureLoginArgs {
|
export default class UnsecureLoginArgs {
|
||||||
@ -8,6 +8,6 @@ export default class UnsecureLoginArgs {
|
|||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
password: string
|
password: string
|
||||||
|
|
||||||
@Field(() => Number, { nullable: true })
|
@Field(() => Int, { nullable: true })
|
||||||
publisherId: number
|
publisherId: number
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* 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'
|
import { KlickTipp } from './KlickTipp'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
@ -66,8 +66,8 @@ export class User {
|
|||||||
groupId: number
|
groupId: number
|
||||||
*/
|
*/
|
||||||
// what is publisherId?
|
// what is publisherId?
|
||||||
@Field(() => Number)
|
@Field(() => Int, { nullable: true })
|
||||||
publisherId: number
|
publisherId?: number
|
||||||
|
|
||||||
@Field(() => Boolean)
|
@Field(() => Boolean)
|
||||||
coinanimation: boolean
|
coinanimation: boolean
|
||||||
|
|||||||
@ -48,6 +48,9 @@ export class UserResolver {
|
|||||||
value: encode(result.data.session_id, result.data.user.public_hex),
|
value: encode(result.data.session_id, result.data.user.public_hex),
|
||||||
})
|
})
|
||||||
const user = new User(result.data.user)
|
const user = new User(result.data.user)
|
||||||
|
if (user.publisherId === 0) {
|
||||||
|
user.publisherId = undefined
|
||||||
|
}
|
||||||
user.hasElopage = result.data.hasElopage
|
user.hasElopage = result.data.hasElopage
|
||||||
// read additional settings from settings table
|
// read additional settings from settings table
|
||||||
const userRepository = getCustomRepository(UserRepository)
|
const userRepository = getCustomRepository(UserRepository)
|
||||||
@ -68,8 +71,7 @@ export class UserResolver {
|
|||||||
throw new Error('error with cannot happen')
|
throw new Error('error with cannot happen')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publisherId) {
|
if (!user.hasElopage && publisherId) {
|
||||||
// Save it
|
|
||||||
user.publisherId = publisherId
|
user.publisherId = publisherId
|
||||||
await this.updateUserInfos(
|
await this.updateUserInfos(
|
||||||
{ publisherId },
|
{ publisherId },
|
||||||
@ -115,7 +117,7 @@ export class UserResolver {
|
|||||||
|
|
||||||
@Mutation(() => String)
|
@Mutation(() => String)
|
||||||
async createUser(
|
async createUser(
|
||||||
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
|
@Args() { email, firstName, lastName, password, language, publisherId }: CreateUserArgs,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const payload = {
|
const payload = {
|
||||||
email,
|
email,
|
||||||
@ -125,7 +127,7 @@ export class UserResolver {
|
|||||||
emailType: 2,
|
emailType: 2,
|
||||||
login_after_register: true,
|
login_after_register: true,
|
||||||
language: language,
|
language: language,
|
||||||
publisher_id: 0,
|
publisher_id: publisherId,
|
||||||
}
|
}
|
||||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'createUser', payload)
|
const result = await apiPost(CONFIG.LOGIN_API_URL + 'createUser', payload)
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user