From cccd8262fa78dabc8e1949c4dcb490b99fb0cd84 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Sat, 8 May 2021 16:03:03 -0400 Subject: [PATCH] admin: Add /users/ route Individual user information can now be looked up by UUID. --- src/api/admin.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/admin.rs b/src/api/admin.rs index c3e53784..34875d7a 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -30,6 +30,7 @@ pub fn routes() -> Vec { routes![ admin_login, get_users_json, + get_user_json, post_admin_login, admin_page, invite_user, @@ -349,6 +350,13 @@ fn users_overview(_token: AdminToken, conn: DbConn) -> ApiResult> { Ok(Html(text)) } +#[get("/users/")] +fn get_user_json(uuid: String, _token: AdminToken, conn: DbConn) -> JsonResult { + let user = User::find_by_uuid(&uuid, &conn).map_res("User doesn't exist")?; + + Ok(Json(user.to_json(&conn))) +} + #[post("/users//delete")] fn delete_user(uuid: String, _token: AdminToken, conn: DbConn) -> EmptyResult { let user = User::find_by_uuid(&uuid, &conn).map_res("User doesn't exist")?;