diff options
author | MS <ms@taler.net> | 2023-02-03 17:50:42 +0100 |
---|---|---|
committer | MS <ms@taler.net> | 2023-02-03 17:50:42 +0100 |
commit | 2fa10d5f5a5eeacb1b4407ed9479dd2cb5cff4f9 (patch) | |
tree | fed83d6f363c2125bac1c14f7901c65bf455ae07 /sandbox/src/main/kotlin/tech/libeufin | |
parent | 3376028b1b3129ddf30ef029aab543e343e57b7c (diff) | |
download | libeufin-2fa10d5f5a5eeacb1b4407ed9479dd2cb5cff4f9.tar.gz libeufin-2fa10d5f5a5eeacb1b4407ed9479dd2cb5cff4f9.tar.bz2 libeufin-2fa10d5f5a5eeacb1b4407ed9479dd2cb5cff4f9.zip |
EBICS subscriber creation.
Checking whether the EBICS host exists
before adding the new subscriber.
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin')
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt index 072a5acc..56e2ddb1 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -132,11 +132,11 @@ class Config : CliktCommand("Insert one configuration (a.k.a. demobank) into the private val usersDebtLimitOption by option("--users-debt-limit").int().default(1000) private val allowRegistrationsOption by option( "--with-registrations", - help = "(default: true)" /* mentioning here as help message did not. */ + help = "(defaults to allow registrations)" /* mentioning here as help message did not. */ ).flag("--without-registrations", default = true) private val withSignupBonusOption by option( "--with-signup-bonus", - help = "Award new customers with 100 units of currency! (default: false)" + help = "Award new customers with 100 units of currency! (defaults to NO bonus)" ).flag("--without-signup-bonus", default = false) override fun run() { @@ -937,13 +937,16 @@ val sandboxApp: Application.() -> Unit = { call.request.basicAuth(onlyAdmin = true) val body = call.receive<EbicsSubscriberObsoleteApi>() transaction { + // Check the host ID exists. + val maybeHostId = EbicsHostEntity.find { + EbicsHostsTable.hostID eq body.hostID + }.firstOrNull() ?: throw notFound("Host ID ${body.hostID} not found.") // Check it exists first. val maybeSubscriber = EbicsSubscriberEntity.find { EbicsSubscribersTable.userId eq body.userID and ( EbicsSubscribersTable.partnerId eq body.partnerID - ) and ( - EbicsSubscribersTable.systemId eq body.systemID - ) + ) and (EbicsSubscribersTable.systemId eq body.systemID) and + (EbicsSubscribersTable.hostId eq body.hostID) }.firstOrNull() if (maybeSubscriber != null) throw conflict("EBICS subscriber exists already") EbicsSubscriberEntity.new { @@ -1581,6 +1584,10 @@ val sandboxApp: Application.() -> Unit = { val body = call.receive<EbicsSubscriberInfo>() // Create or get the Ebics subscriber that is found. transaction { + // Check that host ID exists + EbicsHostEntity.find { + EbicsHostsTable.hostID eq body.hostID + }.firstOrNull() ?: throw notFound("Host ID ${body.hostID} not found.") val subscriber: EbicsSubscriberEntity = EbicsSubscriberEntity.find { (EbicsSubscribersTable.partnerId eq body.partnerID).and( EbicsSubscribersTable.userId eq body.userID |