changes requested

This commit is contained in:
Moriz Wahl 2023-03-28 13:32:47 +02:00
parent ed8549bfb5
commit d7919ea10f
3 changed files with 5 additions and 6 deletions

View File

@ -304,7 +304,7 @@ export class TransactionResolver {
@Args() { identifier, amount, memo }: TransactionSendArgs, @Args() { identifier, amount, memo }: TransactionSendArgs,
@Ctx() context: Context, @Ctx() context: Context,
): Promise<boolean> { ): Promise<boolean> {
logger.info(`sendCoins(email=${email}, amount=${amount}, memo=${memo})`) logger.info(`sendCoins(identifier=${identifier}, amount=${amount}, memo=${memo})`)
if (amount.lte(0)) { if (amount.lte(0)) {
throw new LogError('Amount to send must be positive', amount) throw new LogError('Amount to send must be positive', amount)
} }

View File

@ -823,10 +823,9 @@ export class UserResolver {
} }
@Authorized([RIGHTS.USER]) @Authorized([RIGHTS.USER])
@Query(() => User, { nullable: true }) @Query(() => User)
async user(@Arg('identifier') identifier: string): Promise<User | null> { async user(@Arg('identifier') identifier: string): Promise<User> {
const user = await findUserByIdentifier(identifier) return new User(await findUserByIdentifier(identifier))
return user ? new User(user) : null
} }
} }

View File

@ -3,7 +3,7 @@ import { UserContact as DbUserContact } from '@entity/UserContact'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { validate, version } from 'uuid' import { validate, version } from 'uuid'
export const findUserByIdentifier = async (identifier: string): Promise<DbUser | null> => { export const findUserByIdentifier = async (identifier: string): Promise<DbUser> => {
let user: DbUser | undefined let user: DbUser | undefined
if (validate(identifier) && version(identifier) === 4) { if (validate(identifier) && version(identifier) === 4) {
user = await DbUser.findOne({ where: { gradidoID: identifier }, relations: ['emailContact'] }) user = await DbUser.findOne({ where: { gradidoID: identifier }, relations: ['emailContact'] })