Merge pull request #19 from fLotte-meets-HWR-DB/develop

Change /users to also include user roles
leon_tries_rust
Trivernis 4 years ago committed by GitHub
commit eca80e3d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -227,7 +227,7 @@ impl UserHttpServer {
"GET", "GET",
"See user information", "See user information",
)?; )?;
doc.add_path::<(), Vec<UserInformation>>( doc.add_path::<(), Vec<UserFullInformation>>(
"/users", "/users",
"GET", "GET",
"Returns information for all users", "Returns information for all users",
@ -410,8 +410,20 @@ impl UserHttpServer {
fn get_users(database: &Database, request: &Request) -> HTTPResult<Response> { fn get_users(database: &Database, request: &Request) -> HTTPResult<Response> {
require_permission!(database, request, USER_VIEW_PERM); require_permission!(database, request, USER_VIEW_PERM);
let users = database.users.get_users()?; let users = database.users.get_users()?;
let mut full_information = Vec::new();
Ok(Response::json(&users)) 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(&full_information))
} }
/// Creates a new user /// Creates a new user

Loading…
Cancel
Save