From 9979e8c9d513356c6210b06822c64ab410fa453b Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 1 Dec 2020 20:19:05 +0100 Subject: [PATCH] Change /users to also include user roles Signed-off-by: trivernis --- src/server/http_server.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/server/http_server.rs b/src/server/http_server.rs index 1713cb2..2c5ce26 100644 --- a/src/server/http_server.rs +++ b/src/server/http_server.rs @@ -227,7 +227,7 @@ impl UserHttpServer { "GET", "See user information", )?; - doc.add_path::<(), Vec>( + doc.add_path::<(), Vec>( "/users", "GET", "Returns information for all users", @@ -410,8 +410,20 @@ impl UserHttpServer { fn get_users(database: &Database, request: &Request) -> HTTPResult { require_permission!(database, request, USER_VIEW_PERM); let users = database.users.get_users()?; + let mut full_information = Vec::new(); + + for user in users { + let roles = database.user_roles.by_user(user.id)?; + full_information.push(UserFullInformation { + id: user.id, + name: user.name, + attributes: user.attributes, + email: user.email, + roles, + }); + } - Ok(Response::json(&users)) + Ok(Response::json(&full_information)) } /// Creates a new user