Adding the publisherId to the login call and that it stores it to the user profile.

This commit is contained in:
elweyn 2021-10-13 12:07:23 +02:00
parent f039f8a714
commit 5a14161284
4 changed files with 17 additions and 5 deletions

View File

@ -7,4 +7,7 @@ export default class UnsecureLoginArgs {
@Field(() => String)
password: string
@Field(() => Number, { nullable: true })
publisherId: number
}

View File

@ -19,7 +19,6 @@ export class User {
this.pubkey = json.public_hex
this.language = json.language
this.publisherId = json.publisher_id
this.hasElopage = json.hasElopage
}
@Field(() => String)

View File

@ -31,7 +31,10 @@ import { UserRepository } from '../../typeorm/repository/User'
export class UserResolver {
@Query(() => User)
@UseMiddleware(klicktippNewsletterStateMiddleware)
async login(@Args() { email, password }: UnsecureLoginArgs, @Ctx() context: any): Promise<User> {
async login(
@Args() { email, password, publisherId }: UnsecureLoginArgs,
@Ctx() context: any,
): Promise<User> {
email = email.trim().toLowerCase()
const result = await apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', { email, password })
@ -65,6 +68,15 @@ export class UserResolver {
throw new Error('error with cannot happen')
}
if (publisherId) {
// Save it
user.publisherId = publisherId
await this.updateUserInfos(
{ publisherId },
{ sessionId: result.data.session_id, pubKey: result.data.user.public_hex },
)
}
const userSettingRepository = getCustomRepository(UserSettingRepository)
const coinanimation = await userSettingRepository
.readBoolean(userEntity.id, Setting.COIN_ANIMATION)

View File

@ -29,9 +29,7 @@ export const klicktippNewsletterStateMiddleware: MiddlewareFn = async (
if (klickTippUser) {
klickTipp = new KlickTipp(klickTippUser)
}
} catch (err) {
console.log('Something went wrong', err)
}
} catch (err) {}
}
result.klickTipp = klickTipp
return result