diff options
author | Marcello Stanisci <ms@taler.net> | 2020-05-08 18:26:08 +0200 |
---|---|---|
committer | Marcello Stanisci <ms@taler.net> | 2020-05-08 18:26:08 +0200 |
commit | 089a03b96a074731b058a5d5576837203a48386a (patch) | |
tree | 009e2833b32141e1d6f4ed2d830c2207bde0714f /nexus/src/main | |
parent | e732d76b2ea1f6095186a1b5b84926573d620f8b (diff) | |
download | libeufin-089a03b96a074731b058a5d5576837203a48386a.tar.gz libeufin-089a03b96a074731b058a5d5576837203a48386a.tar.bz2 libeufin-089a03b96a074731b058a5d5576837203a48386a.zip |
add GET /bank-accounts, fix GET /user.
Diffstat (limited to 'nexus/src/main')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 6 | ||||
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 27 |
2 files changed, 24 insertions, 9 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt index ed7d62bb..3f12e3ad 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt @@ -95,6 +95,12 @@ data class NexusUser( val transports: MutableList<Any> = mutableListOf() ) +/** is "UserResponse" in the API spec */ +data class UserResponse( + val username: String, + val superuser: Boolean +) + /** Instructs the nexus to CREATE a new user */ data class User( val username: String, diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt index f4c58141..ec1f3f57 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -133,17 +133,14 @@ fun main() { */ get("/user") { val userId = authenticateRequest(call.request.headers["Authorization"]) - val bankAccounts = BankAccounts() - getBankAccountsFromNexusUserId(userId).forEach { - bankAccounts.accounts.add( - BankAccount( - holder = it.accountHolder, - iban = it.iban, - bic = it.bankCode, - account = it.id.value - ) + val ret = transaction { + NexusUserEntity.findById(userId) + UserResponse( + username = userId, + superuser = userId.equals("admin") ) } + call.respond(HttpStatusCode.OK, ret) return@get } /** @@ -172,6 +169,18 @@ fun main() { * Shows the bank accounts belonging to the requesting user. */ get("/bank-accounts") { + val userId = authenticateRequest(call.request.headers["Authorization"]) + val bankAccounts = BankAccounts() + getBankAccountsFromNexusUserId(userId).forEach { + bankAccounts.accounts.add( + BankAccount( + holder = it.accountHolder, + iban = it.iban, + bic = it.bankCode, + account = it.id.value + ) + ) + } return@get } /** |