gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant-backoffice] branch master updated: input validation


From: gnunet
Subject: [taler-merchant-backoffice] branch master updated: input validation
Date: Fri, 08 Apr 2022 23:17:53 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository merchant-backoffice.

The following commit(s) were added to refs/heads/master by this push:
     new d972287  input validation
d972287 is described below

commit d972287890401efa538cd0bb1b8e27505782d7d5
Author: ms <ms@taler.net>
AuthorDate: Fri Apr 8 23:17:25 2022 +0200

    input validation
---
 packages/bank/src/pages/home/index.tsx | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/packages/bank/src/pages/home/index.tsx 
b/packages/bank/src/pages/home/index.tsx
index 424d5b7..69f9f06 100644
--- a/packages/bank/src/pages/home/index.tsx
+++ b/packages/bank/src/pages/home/index.tsx
@@ -127,13 +127,16 @@ function goPublicAccounts(pageStateSetter: 
StateUpdater<PageStateType>) {
  */
 function validateAmount(maybeAmount: string): any {
   const amountRegex = "^[0-9]+(\.[0-9]+)?$";
+  if (!maybeAmount) {
+    console.log(`Entered amount (${maybeAmount}) mismatched <input> pattern.`);
+    return;
+  }
   if (typeof maybeAmount !== "undefined" || maybeAmount !== "") {
     console.log("Maybe valid amount: " + maybeAmount);
     // tolerating comma instead of point.
-    maybeAmount = maybeAmount.replace(",", ".");
     const re = RegExp(amountRegex)
     if (!re.test(maybeAmount)) {
-      console.log(`Not withdrawing invalid amount '${maybeAmount}'.`);
+      console.log(`Not using invalid amount '${maybeAmount}'.`);
       return false;
     }
   }
@@ -782,20 +785,20 @@ function PaytoWireTransfer(Props: any): VNode {
             pattern={amountRegex}
             onInput={(e): void => {
               amountInput = e.currentTarget.value;
-            }} />&nbsp;<label>{`${currency}:X.Y`}</label><br /><br />
+            }} />&nbsp;<label>{currency}</label><br /><br />
           <input
             type="submit"
             onClick={() => {
-              amountInput = validateAmount(amountInput);
+              amountInput = amountInput.replace(",", ".");
+              if (!validateAmount(amountInput)) return;
               /**
                * By invalid amounts, the validator prints error messages
                * on the console, and the browser colourizes the amount input
                * box to indicate a error.
                */
-              if (!amountInput) return;
               if (!RegExp(ibanRegex).test(receiverInput)) return;
               transactionData = {
-                paytoUri: 
`payto://iban/${receiverInput}?message=${subjectInput}`,
+                paytoUri: 
`payto://iban/${receiverInput}?message=${encodeURIComponent(subjectInput)}`,
                 amount: `${currency}:${amountInput}`
               };
               createTransactionCall(
@@ -1364,7 +1367,9 @@ function Account(Props: any): VNode {
       {logOut}<br />
     </div>
     <section id="menu">
-      <p>{i18n`Bank account balance:`} <br /> <b>{`${balance.value} 
${balance.currency}`}</b></p>
+      <p>{i18n`Bank account balance:`} <br />
+      { data.balance.credit_debit_indicator == "debit" ? (<b>-</b>) : null }
+      <b>{`${balance.value} ${balance.currency}`}</b></p>
     </section>
     <CurrencyContext.Provider value={balance.currency}>
       {Props.children}
@@ -1474,7 +1479,7 @@ function PublicHistories(Props: any): VNode {
     setShowAccount(data.publicAccounts[1].accountLabel);
   console.log(`Public history tab: ${showAccount}`);
 
-  // Ask first story of all the public accounts.
+  // Ask story of all the public accounts.
   for (const account of data.publicAccounts) {
     console.log("Asking transactions for", account.accountLabel)
     const isSelected = account.accountLabel == showAccount;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]