From 25c4c7362febdf950fc610af0ea9fd6a67c1c7e0 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner Date: Fri, 11 Apr 2025 16:40:36 +0200 Subject: [PATCH] now the jwt-token creation and community-switch works correctly, but redeem with a jwt-token is still open --- backend/src/graphql/arg/RedeemJwtArgs.ts | 16 ++++---- .../resolver/TransactionLinkResolver.ts | 40 +++++++++++-------- .../RedeemCommunitySelection.vue | 21 ++++++---- frontend/src/graphql/mutations.js | 10 ++--- frontend/src/pages/TransactionLink.vue | 2 +- 5 files changed, 52 insertions(+), 37 deletions(-) diff --git a/backend/src/graphql/arg/RedeemJwtArgs.ts b/backend/src/graphql/arg/RedeemJwtArgs.ts index bd3feb1d6..e9634d8ec 100644 --- a/backend/src/graphql/arg/RedeemJwtArgs.ts +++ b/backend/src/graphql/arg/RedeemJwtArgs.ts @@ -9,29 +9,29 @@ import { IsPositiveDecimal } from '@/graphql/validator/Decimal' @ArgsType() export class RedeemJwtArgs { @Field(() => String, { nullable: false }) - gradidoID: string + gradidoID!: string @Field(() => String, { nullable: true }) - alias?: string | null + firstName?: string @Field(() => String, { nullable: true }) - firstName?: string | null + alias?: string @Field(() => String, { nullable: false }) - communityUuid: string + communityUuid!: string @Field(() => String, { nullable: false }) - communityName: string + communityName!: string @Field(() => String, { nullable: false }) - code: string + code!: string @Field(() => Decimal, { nullable: false }) @IsPositiveDecimal() - amount: Decimal + amount!: Decimal @Field(() => String, { nullable: false }) @MaxLength(MEMO_MAX_CHARS) @MinLength(MEMO_MIN_CHARS) - memo: string + memo!: string } diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index f5ccb03f0..e51181021 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -11,7 +11,6 @@ import { Decimal } from 'decimal.js-light' import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql' import { Paginated } from '@arg/Paginated' -import { RedeemJwtArgs } from '@arg/RedeemJwtArgs' import { TransactionLinkArgs } from '@arg/TransactionLinkArgs' import { TransactionLinkFilters } from '@arg/TransactionLinkFilters' import { ContributionCycleType } from '@enum/ContributionCycleType' @@ -402,25 +401,34 @@ export class TransactionLinkResolver { @Authorized([RIGHTS.QUERY_REDEEM_JWT]) @Mutation(() => String) - async createRedeemJwt(@Args() redeemJwtArgs: RedeemJwtArgs): Promise { + async createRedeemJwt( + @Arg('gradidoID') gradidoID: string, + @Arg('communityUuid') communityUuid: string, + @Arg('communityName') communityName: string, + @Arg('code') code: string, + @Arg('amount') amount: string, + @Arg('memo') memo: string, + @Arg('firstName', { nullable: true }) firstName?: string, + @Arg('alias', { nullable: true }) alias?: string, + ): Promise { logger.debug('TransactionLinkResolver.queryRedeemJwt... args=', { - gradidoID: redeemJwtArgs.gradidoID, - alias: redeemJwtArgs.alias, - firstName: redeemJwtArgs.firstName, - communityUuid: redeemJwtArgs.communityUuid, - communityName: redeemJwtArgs.communityName, - code: redeemJwtArgs.code, - amount: redeemJwtArgs.amount, - memo: redeemJwtArgs.memo, + gradidoID, + communityUuid, + communityName, + code, + amount, + memo, + firstName, + alias, }) const disbursementJwtPayloadType = new DisbursementJwtPayloadType( - redeemJwtArgs.communityUuid, - redeemJwtArgs.gradidoID, - redeemJwtArgs.alias ?? redeemJwtArgs.firstName ?? '', - redeemJwtArgs.code, - redeemJwtArgs.amount.toString(), - redeemJwtArgs.memo, + communityUuid, + gradidoID, + alias ?? firstName ?? '', + code, + amount, + memo, ) const homeCom = await getHomeCommunity() if (!homeCom.privateKey) { diff --git a/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue b/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue index 3d2febe66..0ef16f25a 100644 --- a/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue +++ b/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue @@ -74,20 +74,27 @@ async function onSwitch(event) { event.preventDefault() // Prevent the default navigation console.log('RedeemCommunitySelection.onSwitch... props=', props) if (isForeignCommunitySelected.value) { - const redeemJwtArgs = { + console.log('RedeemCommunitySelection.onSwitch vor createRedeemJwt params:', { gradidoID: props.linkData.user.gradidoID, - firstName: props.linkData.user.firstName, - alias: props.linkData.user.alias, communityUuid: props.targetCommunity.uuid, communityName: props.targetCommunity.name, code: props.redeemCode, amount: props.linkData.amount, memo: props.linkData.memo, - } - - console.log('RedeemCommunitySelection.onSwitch vor createRedeemJwt params:', redeemJwtArgs) + firstName: props.linkData.user.firstName, + alias: props.linkData.user.alias, + }) try { - const { data } = await createRedeemJwt({ variables: redeemJwtArgs }) + const { data } = await createRedeemJwt({ + gradidoID: props.linkData.user.gradidoID, + communityUuid: props.targetCommunity.uuid, + communityName: props.targetCommunity.name, + code: props.redeemCode, + amount: props.linkData.amount, + memo: props.linkData.memo, + firstName: props.linkData.user.firstName, + alias: props.linkData.user.alias, + }) console.log('RedeemCommunitySelection.onSwitch... response=', data) if (!data?.createRedeemJwt) { throw new Error('Failed to get redeem token') diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index 0a5a4652b..10ed5944a 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -202,23 +202,23 @@ export const logout = gql` export const createRedeemJwtMutation = gql` mutation ( $gradidoID: String! - $firstName: String! - $alias: String! $communityUuid: String! $communityName: String! $code: String! - $amount: Decimal! + $amount: String! $memo: String! + $firstName: String + $alias: String ) { createRedeemJwt( gradidoID: $gradidoID - firstName: $firstName - alias: $alias communityUuid: $communityUuid communityName: $communityName code: $code amount: $amount memo: $memo + firstName: $firstName + alias: $alias ) } ` diff --git a/frontend/src/pages/TransactionLink.vue b/frontend/src/pages/TransactionLink.vue index 4350a0246..c45e5a32f 100644 --- a/frontend/src/pages/TransactionLink.vue +++ b/frontend/src/pages/TransactionLink.vue @@ -54,7 +54,7 @@ const { d, t } = useI18n() const linkData = ref({ __typename: 'TransactionLink', - amount: '', + amount: 0, memo: '', user: null, deletedAt: null,