[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 07/08: add GET /bank-accounts, fix GET /user.
From: |
gnunet |
Subject: |
[libeufin] 07/08: add GET /bank-accounts, fix GET /user. |
Date: |
Fri, 08 May 2020 20:04:51 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit 089a03b96a074731b058a5d5576837203a48386a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri May 8 18:26:08 2020 +0200
add GET /bank-accounts, fix GET /user.
---
nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 6 +++++
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 ed7d62b..3f12e3a 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 f4c5814..ec1f3f5 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
}
/**
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [libeufin] branch master updated (64b3929 -> f73bdad), gnunet, 2020/05/08
- [libeufin] 04/08: GET /user, gnunet, 2020/05/08
- [libeufin] 01/08: Comments., gnunet, 2020/05/08
- [libeufin] 06/08: POST /users, gnunet, 2020/05/08
- [libeufin] 02/08: new API., gnunet, 2020/05/08
- [libeufin] 05/08: admin authentication helper, gnunet, 2020/05/08
- [libeufin] 03/08: fix compilation, gnunet, 2020/05/08
- [libeufin] 07/08: add GET /bank-accounts, fix GET /user.,
gnunet <=
- [libeufin] 08/08: POST preapred-payments/submit, gnunet, 2020/05/08