mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
now the jwt-token creation and community-switch works correctly, but
redeem with a jwt-token is still open
This commit is contained in:
parent
721f9eb8c5
commit
25c4c7362f
@ -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
|
||||
}
|
||||
|
||||
@ -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<string> {
|
||||
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<string> {
|
||||
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) {
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -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
|
||||
)
|
||||
}
|
||||
`
|
||||
|
||||
@ -54,7 +54,7 @@ const { d, t } = useI18n()
|
||||
|
||||
const linkData = ref({
|
||||
__typename: 'TransactionLink',
|
||||
amount: '',
|
||||
amount: 0,
|
||||
memo: '',
|
||||
user: null,
|
||||
deletedAt: null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user