mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
replace implementation of getPublicKey to no longer require the sessionId. Furthermore the call now no longer calls getUserInfos on the login_server but just queries the database itself
This commit is contained in:
parent
b54558fa68
commit
f09c3b4964
@ -33,6 +33,7 @@ import { calculateDecay, calculateDecayWithInterval } from '../../util/decay'
|
|||||||
import { TransactionTypeId } from '../enum/TransactionTypeId'
|
import { TransactionTypeId } from '../enum/TransactionTypeId'
|
||||||
import { TransactionType } from '../enum/TransactionType'
|
import { TransactionType } from '../enum/TransactionType'
|
||||||
import { hasUserAmount, isHexPublicKey } from '../../util/validate'
|
import { hasUserAmount, isHexPublicKey } from '../../util/validate'
|
||||||
|
import { LoginUserRepository } from '../../typeorm/repository/LoginUser'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
# Test
|
# Test
|
||||||
@ -451,15 +452,15 @@ async function addUserTransaction(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPublicKey(email: string, sessionId: number): Promise<string | undefined> {
|
async function getPublicKey(email: string): Promise<string | null> {
|
||||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'getUserInfos', {
|
const loginUserRepository = getCustomRepository(LoginUserRepository)
|
||||||
session_id: sessionId,
|
const loginUser = await loginUserRepository.findOne({ email: email })
|
||||||
email,
|
// User not found
|
||||||
ask: ['user.pubkeyhex'],
|
if (!loginUser) {
|
||||||
})
|
return null
|
||||||
if (result.success) {
|
|
||||||
return result.data.userData.pubkeyhex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return loginUser.pubKey.toString('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
@ -517,7 +518,7 @@ export class TransactionResolver {
|
|||||||
|
|
||||||
// validate recipient user
|
// validate recipient user
|
||||||
// TODO: the detour over the public key is unnecessary
|
// TODO: the detour over the public key is unnecessary
|
||||||
const recipiantPublicKey = await getPublicKey(email, context.sessionId)
|
const recipiantPublicKey = await getPublicKey(email)
|
||||||
if (!recipiantPublicKey) {
|
if (!recipiantPublicKey) {
|
||||||
throw new Error('recipiant not known')
|
throw new Error('recipiant not known')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user