[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 05/07: drafting bank config table
From: |
gnunet |
Subject: |
[libeufin] 05/07: drafting bank config table |
Date: |
Tue, 29 Jun 2021 15:59:16 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit c9a3b09f2245ef48ee42c72aa61cd88e936b2f6a
Author: ms <ms@taler.net>
AuthorDate: Tue Jun 29 12:40:30 2021 +0200
drafting bank config table
---
sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 21 ++++++++++++++++++++-
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 10 +++++-----
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index a83300a..a210163 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -22,10 +22,13 @@ package tech.libeufin.sandbox
import org.jetbrains.exposed.dao.Entity
import org.jetbrains.exposed.dao.EntityClass
import org.jetbrains.exposed.dao.IntEntity
+import org.jetbrains.exposed.dao.LongEntity
import org.jetbrains.exposed.dao.IntEntityClass
+import org.jetbrains.exposed.dao.LongEntityClass
import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.dao.id.IntIdTable
+import org.jetbrains.exposed.dao.id.LongIdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.transactions.transaction
@@ -84,10 +87,26 @@ enum class KeyState {
RELEASED
}
+object SandboxConfigsTable : LongIdTable() {
+ val currency = text("currency")
+ val allowRegistrations = bool("allowRegistrations")
+ val bankDebtLimit = integer("bankDebtLimit")
+ val usersDebtLimit = integer("usersDebtLimit")
+}
+
+class SandboxConfigEntity(id: EntityID<Long>) : LongEntity(id) {
+ companion object :
LongEntityClass<SandboxConfigEntity>(SandboxConfigsTable)
+ var currency by SandboxConfigsTable.currency
+ var allowRegistrations by SandboxConfigsTable.allowRegistrations
+ var bankDebtLimit by SandboxConfigsTable.bankDebtLimit
+ var usersDebtLimit by SandboxConfigsTable.usersDebtLimit
+}
+
object SandboxUsersTable : LongIdTable() {
val username = text("username")
val passwordHash = text("password")
val superuser = bool("superuser") // admin
+ val bankAccount = reference("bankAccout", BankAccountsTable)
}
class SandboxUserEntity(id: EntityID<Long>) : LongEntity(id) {
@@ -95,6 +114,7 @@ class SandboxUserEntity(id: EntityID<Long>) : LongEntity(id)
{
var username by SandboxUsersTable.username
var passwordHash by SandboxUsersTable.passwordHash
var superuser by SandboxUsersTable.superuser
+ var bankAccount by BankAccountEntity referencedOn
SandboxUsersTable.bankAccount
}
@@ -108,7 +128,6 @@ object EbicsSubscriberPublicKeysTable : IntIdTable() {
class EbicsSubscriberPublicKeyEntity(id: EntityID<Int>) : IntEntity(id) {
companion object :
IntEntityClass<EbicsSubscriberPublicKeyEntity>(EbicsSubscriberPublicKeysTable)
-
var rsaPublicKey by EbicsSubscriberPublicKeysTable.rsaPublicKey
var state by EbicsSubscriberPublicKeysTable.state
}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 20e75a1..2d024db 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -331,9 +331,9 @@ fun serverMain(dbName: String, port: Int) {
transaction {
// check if username is taken.
- val maybeUser = SandboxUserEntity.find(
- SandboxUserTable.username eq username
- ).firstOrNull()
+ var maybeUser = SandboxUserEntity.find {
+ SandboxUsersTable.username eq username
+ }.firstOrNull()
// Will be converted to a HTML response.
if (maybeUser != null) throw SandboxError(
HttpStatusCode.Conflict, "Username not available"
@@ -341,9 +341,9 @@ fun serverMain(dbName: String, port: Int) {
// username is valid. Register the user + new bank
account.
SandboxUserEntity.new {
- username = username
+ this.username = username
passwordHash = CryptoUtil.hashpw(password)
- superuser = false
+ this.superuser = superuser
bankAccount = BankAccountEntity.new {
iban = "fixme"
bic = "fixme"
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (62d0490 -> 786b70a), gnunet, 2021/06/29
- [libeufin] 05/07: drafting bank config table,
gnunet <=
- [libeufin] 07/07: helper that returns a bank configuration, given the hostname., gnunet, 2021/06/29
- [libeufin] 06/07: CLI command to configure the Sandbox, gnunet, 2021/06/29
- [libeufin] 01/07: DB: making Ebics subscriber point at bank accounts., gnunet, 2021/06/29
- [libeufin] 02/07: Commenting out Jinja initialization., gnunet, 2021/06/29
- [libeufin] 03/07: Jinja and form-auth experiments, gnunet, 2021/06/29
- [libeufin] 04/07: drafting user creation, gnunet, 2021/06/29