mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
HasElopage has been called, search loginUser catch instead of if no user, context get's the pubKey at the end of the login call instead of the start.
This commit is contained in:
parent
7655a647fe
commit
1baf756c08
@ -31,6 +31,7 @@ import { LoginElopageBuys } from '@entity/LoginElopageBuys'
|
||||
import { LoginUserBackup } from '@entity/LoginUserBackup'
|
||||
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
|
||||
import { sendEMail } from '../../util/sendEMail'
|
||||
import { LoginElopageBuysRepository } from '../../typeorm/repository/LoginElopageBuys'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const sodium = require('sodium-native')
|
||||
@ -195,14 +196,9 @@ export class UserResolver {
|
||||
// const result = await apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', { email, password })
|
||||
// UnsecureLogin
|
||||
const loginUserRepository = getCustomRepository(LoginUserRepository)
|
||||
const loginUser = await loginUserRepository.findByEmail(email)
|
||||
if (!loginUser) {
|
||||
const loginUser = await loginUserRepository.findByEmail(email).catch(() => {
|
||||
throw new Error('No user with this credentials')
|
||||
}
|
||||
if (!isPassword(password)) {
|
||||
throw new Error('No user with this credentials')
|
||||
}
|
||||
|
||||
})
|
||||
const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
|
||||
const loginUserPassword = BigInt(loginUser.password.toString())
|
||||
if (loginUserPassword !== passwordHash[0].readBigUInt64LE()) {
|
||||
@ -210,11 +206,6 @@ export class UserResolver {
|
||||
}
|
||||
// TODO: If user has no pubKey Create it again and update user.
|
||||
|
||||
context.setHeaders.push({
|
||||
key: 'token',
|
||||
value: encode(loginUser.pubKey),
|
||||
})
|
||||
|
||||
const userRepository = getCustomRepository(UserRepository)
|
||||
let userEntity: void | DbUser
|
||||
const loginUserPubKey = loginUser.pubKey
|
||||
@ -244,11 +235,7 @@ export class UserResolver {
|
||||
user.description = loginUser.description
|
||||
user.pubkey = loginUserPubKeyString
|
||||
user.language = loginUser.language
|
||||
// TODO: Get Method from PR (hasElopage)
|
||||
// auto elopage_buy = Poco::AutoPtr<model::table::ElopageBuy>(new model::table::ElopageBuy);
|
||||
// mHasElopage = elopage_buy->isExistInDB("payer_email", mEmail);
|
||||
// else undefined
|
||||
// user.hasElopage = result.data.hasElopage
|
||||
user.hasElopage = await this.hasElopage({ pubkey: loginUser.pubKey })
|
||||
|
||||
// TODO: Get Method from PR (publisherId)
|
||||
// Hack: Database Field is not validated properly and not nullable
|
||||
@ -272,6 +259,12 @@ export class UserResolver {
|
||||
throw new Error(error)
|
||||
})
|
||||
user.coinanimation = coinanimation
|
||||
|
||||
context.setHeaders.push({
|
||||
key: 'token',
|
||||
value: encode(loginUser.pubKey),
|
||||
})
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user