mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-20 20:01:31 +00:00
Adding the publisherId to the login call and that it stores it to the user profile.
This commit is contained in:
parent
f039f8a714
commit
5a14161284
@ -7,4 +7,7 @@ export default class UnsecureLoginArgs {
|
||||
|
||||
@Field(() => String)
|
||||
password: string
|
||||
|
||||
@Field(() => Number, { nullable: true })
|
||||
publisherId: number
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user