gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/02: check IBAN conflict


From: gnunet
Subject: [libeufin] 01/02: check IBAN conflict
Date: Mon, 12 Dec 2022 23:12:23 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 83f3fc7c27175af42943a3691f32db646b67a05f
Author: MS <ms@taler.net>
AuthorDate: Mon Dec 12 21:50:46 2022 +0100

    check IBAN conflict
---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index e93dce8d..cde8e6b4 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -54,7 +54,6 @@ import com.github.ajalt.clikt.parameters.options.*
 import com.github.ajalt.clikt.parameters.types.int
 import execThrowableOrTerminate
 import io.ktor.application.*
-import io.ktor.client.statement.*
 import io.ktor.features.*
 import io.ktor.http.*
 import io.ktor.jackson.*
@@ -1517,7 +1516,7 @@ val sandboxApp: Application.() -> Unit = {
                     // Forbid 'admin' or 'bank' usernames.
                     if (req.username == "bank" || req.username == "admin")
                         throw forbidden("Unallowed username: ${req.username}")
-                    val checkExist = transaction {
+                    val checkCustomerExist = transaction {
                         DemobankCustomerEntity.find {
                             DemobankCustomersTable.username eq req.username
                         }.firstOrNull()
@@ -1526,17 +1525,25 @@ val sandboxApp: Application.() -> Unit = {
                      * Not allowing 'bank' username, as it's been assigned
                      * to the default bank's bank account.
                      */
-                    if (checkExist != null) {
+                    if (checkCustomerExist != null) {
                         throw SandboxError(
                             HttpStatusCode.Conflict,
                             "Username ${req.username} not available."
                         )
                     }
+                    val newIban = req.iban ?: getIban()
+                    // Double-check if IBAN was taken already.
+                    val checkIbanExist = transaction {
+                        BankAccountEntity.find(BankAccountsTable.iban eq 
newIban).firstOrNull()
+                    }
+                    if (checkIbanExist != null)
+                        throw conflict("Proposed IBAN not available.")
+
                     // Create new customer.
                     requireValidResourceName(req.username)
                     val bankAccount = transaction {
                         val bankAccount = BankAccountEntity.new {
-                            iban = req.iban ?: getIban()
+                            iban = newIban
                             /**
                              * For now, keep same semantics of Pybank: a 
username
                              * is AS WELL a bank account label.  In other 
words, it

-- 
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]