@@ -323,9 +323,15 @@ export class TransactionController {
323323 if ( transaction . refundTargetEntity instanceof BankTx ) {
324324 // Unassigned transaction
325325 if ( ! BankTxTypeUnassigned ( transaction . bankTx . type ) ) throw new NotFoundException ( 'Transaction not found' ) ;
326- const txOwner = await this . bankTxService . getUserDataForBankTx ( transaction . bankTx , jwt . account ) ;
327- if ( jwt . account !== transaction . userData ?. id || txOwner . id !== jwt . account )
326+
327+ // Check ownership (consistent with requestRefund logic)
328+ if ( transaction . userData && jwt . account !== transaction . userData . id )
328329 throw new ForbiddenException ( 'You can only refund your own transaction' ) ;
330+ if ( ! transaction . userData ) {
331+ const txOwner = await this . bankTxService . getUserDataForBankTx ( transaction . bankTx , jwt . account ) ;
332+ if ( txOwner ?. id !== jwt . account ) throw new ForbiddenException ( 'You can only refund your own transaction' ) ;
333+ }
334+
329335 if ( transaction . refundTargetEntity . bankTxReturn )
330336 throw new BadRequestException ( 'You can only refund a transaction once' ) ;
331337
@@ -421,7 +427,7 @@ export class TransactionController {
421427 throw new ForbiddenException ( 'You can only refund your own transaction' ) ;
422428 if ( ! transaction . targetEntity && ! transaction . userData ) {
423429 const txOwner = await this . bankTxService . getUserDataForBankTx ( transaction . bankTx , jwt . account ) ;
424- if ( txOwner . id !== jwt . account ) throw new ForbiddenException ( 'You can only refund your own transaction' ) ;
430+ if ( txOwner ? .id !== jwt . account ) throw new ForbiddenException ( 'You can only refund your own transaction' ) ;
425431 }
426432
427433 const refundData = this . refundList . get ( transaction . id ) ;
0 commit comments