aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel GarcĂ­a <[email protected]>2019-04-11 20:42:44 +0200
committerGitHub <[email protected]>2019-04-11 20:42:44 +0200
commitf25ab42ebbb3d10c3306ecf1f59321c5787cdf2d (patch)
treedb1a7bece132ae3cc81add1de7e80e7f5d32ae1c
parent3bb46ce496d42d3a55f61cecc65888cc4b5a12cb (diff)
parentd3a8a278e6ee7f51f63eb867f5410bf087dc43ab (diff)
downloadvaultwarden-f25ab42ebbb3d10c3306ecf1f59321c5787cdf2d.tar.gz
vaultwarden-f25ab42ebbb3d10c3306ecf1f59321c5787cdf2d.zip
Merge pull request #455 from ViViDboarder/get_users
Add new endpoint for retrieving all users
-rw-r--r--src/api/admin.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/api/admin.rs b/src/api/admin.rs
index c40f5230..09f18825 100644
--- a/src/api/admin.rs
+++ b/src/api/admin.rs
@@ -6,7 +6,7 @@ use rocket::response::{content::Html, Flash, Redirect};
use rocket::{Outcome, Route};
use rocket_contrib::json::Json;
-use crate::api::{ApiResult, EmptyResult};
+use crate::api::{ApiResult, EmptyResult, JsonResult};
use crate::auth::{decode_admin, encode_jwt, generate_admin_claims, ClientIp};
use crate::config::ConfigBuilder;
use crate::db::{models::*, DbConn};
@@ -21,6 +21,7 @@ pub fn routes() -> Vec<Route> {
routes![
admin_login,
+ get_users,
post_admin_login,
admin_page,
invite_user,
@@ -155,6 +156,14 @@ fn invite_user(data: Json<InviteData>, _token: AdminToken, conn: DbConn) -> Empt
}
}
+#[get("/users")]
+fn get_users(_token: AdminToken, conn: DbConn) ->JsonResult {
+ let users = User::get_all(&conn);
+ let users_json: Vec<Value> = users.iter().map(|u| u.to_json(&conn)).collect();
+
+ Ok(Json(Value::Array(users_json)))
+}
+
#[post("/users/<uuid>/delete")]
fn delete_user(uuid: String, _token: AdminToken, conn: DbConn) -> EmptyResult {
let user = match User::find_by_uuid(&uuid, &conn) {