commit 0a4f8f53f84ad7e172880e0880a670aa651a01a4
parent 266c074d4e9ed45a0a0f54904e3acde2b84417c7
Author: Florian Dold <florian@dold.me>
Date: Sat, 7 Aug 2021 13:13:26 +0200
cli: implement 'users self' subcommand
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli
@@ -86,6 +86,19 @@ def users(ctx):
def permissions(ctx):
ctx.obj = NexusContext()
+@users.command("self", help="Show information about authenticated user.")
+@click.pass_obj
+def users_self(obj):
+ url = urljoin(obj.nexus_base_url, f"/user")
+ try:
+ resp = get(url, auth=auth.HTTPBasicAuth(obj.nexus_username, obj.nexus_password))
+ except Exception as e:
+ print(e)
+ print("Could not reach nexus at " + url)
+ exit(1)
+
+ tell_user(resp, withsuccess=True)
+ check_response_status(resp)
@users.command("list", help="List users")
@click.pass_obj
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -288,7 +288,7 @@ data class PaymentInitiationResponse(
/** Response type of "GET /user" */
data class UserResponse(
val username: String,
- val superuser: Boolean
+ val superuser: Boolean,
)
/** Request type of "POST /users" */