gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]