set validUntil in DisbersementLink by exp-claim of jwt-payload

This commit is contained in:
clauspeterhuebner 2025-04-23 16:23:18 +02:00
parent 09c5aac8e6
commit 3770be4274
2 changed files with 16 additions and 3 deletions

View File

@ -26,6 +26,9 @@ export class DisbursementLink {
this.amount = new Decimal(disbursementPayload.amount)
this.memo = disbursementPayload.memo
this.code = disbursementPayload.redeemcode
if (disbursementPayload.exp) {
this.validUntil = new Date(disbursementPayload.exp)
}
}
@Field(() => Community)
@ -48,4 +51,7 @@ export class DisbursementLink {
@Field(() => String)
code: string
@Field(() => Date)
validUntil: Date
}

View File

@ -190,7 +190,9 @@ export class TransactionLinkResolver {
)
if (
decodedPayload != null &&
decodedPayload.tokentype === DisbursementJwtPayloadType.REDEEM_ACTIVATION_TYPE
decodedPayload.tokentype === DisbursementJwtPayloadType.REDEEM_ACTIVATION_TYPE &&
decodedPayload.exp &&
decodedPayload.exp > new Date().getTime()
) {
const disburseJwtPayload = new DisbursementJwtPayloadType(
decodedPayload.sendercommunityuuid as string,
@ -224,7 +226,9 @@ export class TransactionLinkResolver {
let verifiedPayload: DisbursementJwtPayloadType | null = null
if (
jwtPayload != null &&
jwtPayload.tokentype === DisbursementJwtPayloadType.REDEEM_ACTIVATION_TYPE
jwtPayload.tokentype === DisbursementJwtPayloadType.REDEEM_ACTIVATION_TYPE &&
jwtPayload.exp &&
jwtPayload.exp > new Date().getTime()
) {
verifiedPayload = new DisbursementJwtPayloadType(
jwtPayload.sendercommunityuuid as string,
@ -265,7 +269,10 @@ export class TransactionLinkResolver {
)
return disbursementLink
} else {
throw new LogError('Redeem with wrong type of JWT-Token! decodedPayload=', decodedPayload)
throw new LogError(
'Redeem with wrong type of JWT-Token or expired! decodedPayload=',
decodedPayload,
)
}
}
}