Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit a6fcf06

Browse files
authored
fix: block same account transfers (#54)
1 parent 163ee33 commit a6fcf06

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,6 @@
161161
"no_balance": "No balance",
162162
"no_access": "No access",
163163
"something_went_wrong": "Unknown error, something went wrong",
164-
"account_id_not_exists": "No account with such id found"
164+
"account_id_not_exists": "No account with such id found",
165+
"same_account_transfer": "Cannot transfer money to the same account"
165166
}

src/server/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ onClientCallback(
137137

138138
if (!hasPermission) return;
139139

140+
target = typeof(target) == "string" ? Number.parseInt(target) : target
140141
let targetAccountId = 0;
141142

142143
try {

src/web/src/layouts/bank/pages/accounts/modals/TransferModal.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ const TransferModal: React.FC<{ account: Account }> = ({ account }) => {
6464
message: locales.amount_greater_than_balance,
6565
});
6666

67+
if (values.transferType == 'account' && account.id == values.target)
68+
return form.setError('target', {
69+
type: 'value',
70+
message: locales.same_account_transfer
71+
})
72+
6773
setIsLoading(true);
6874
const resp = await fetchNui<{ success: boolean; message?: string }>(
6975
'transferMoney',

0 commit comments

Comments
 (0)