|
|
|
@ -192,8 +192,8 @@ fn post_organization(
|
|
|
|
|
|
|
|
|
|
// GET /api/collections?writeOnly=false
|
|
|
|
|
#[get("/collections")]
|
|
|
|
|
fn get_user_collections(headers: Headers, conn: DbConn) -> JsonResult {
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
fn get_user_collections(headers: Headers, conn: DbConn) -> Json<Value> {
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Data":
|
|
|
|
|
Collection::find_by_user_uuid(&headers.user.uuid, &conn)
|
|
|
|
|
.iter()
|
|
|
|
@ -201,12 +201,12 @@ fn get_user_collections(headers: Headers, conn: DbConn) -> JsonResult {
|
|
|
|
|
.collect::<Value>(),
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"ContinuationToken": null,
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/organizations/<org_id>/collections")]
|
|
|
|
|
fn get_org_collections(org_id: String, _headers: AdminHeaders, conn: DbConn) -> JsonResult {
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
fn get_org_collections(org_id: String, _headers: AdminHeaders, conn: DbConn) -> Json<Value> {
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Data":
|
|
|
|
|
Collection::find_by_organization(&org_id, &conn)
|
|
|
|
|
.iter()
|
|
|
|
@ -214,7 +214,7 @@ fn get_org_collections(org_id: String, _headers: AdminHeaders, conn: DbConn) ->
|
|
|
|
|
.collect::<Value>(),
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"ContinuationToken": null,
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[post("/organizations/<org_id>/collections", data = "<data>")]
|
|
|
|
@ -441,30 +441,30 @@ struct OrgIdData {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/ciphers/organization-details?<data..>")]
|
|
|
|
|
fn get_org_details(data: Form<OrgIdData>, headers: Headers, conn: DbConn) -> JsonResult {
|
|
|
|
|
fn get_org_details(data: Form<OrgIdData>, headers: Headers, conn: DbConn) -> Json<Value> {
|
|
|
|
|
let ciphers = Cipher::find_by_org(&data.organization_id, &conn);
|
|
|
|
|
let ciphers_json: Vec<Value> = ciphers
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|c| c.to_json(&headers.host, &headers.user.uuid, &conn))
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Data": ciphers_json,
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"ContinuationToken": null,
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/organizations/<org_id>/users")]
|
|
|
|
|
fn get_org_users(org_id: String, _headers: ManagerHeadersLoose, conn: DbConn) -> JsonResult {
|
|
|
|
|
fn get_org_users(org_id: String, _headers: ManagerHeadersLoose, conn: DbConn) -> Json<Value> {
|
|
|
|
|
let users = UserOrganization::find_by_org(&org_id, &conn);
|
|
|
|
|
let users_json: Vec<Value> = users.iter().map(|c| c.to_json_user_details(&conn)).collect();
|
|
|
|
|
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Data": users_json,
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"ContinuationToken": null,
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
@ -930,15 +930,15 @@ fn post_org_import(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/organizations/<org_id>/policies")]
|
|
|
|
|
fn list_policies(org_id: String, _headers: AdminHeaders, conn: DbConn) -> JsonResult {
|
|
|
|
|
fn list_policies(org_id: String, _headers: AdminHeaders, conn: DbConn) -> Json<Value> {
|
|
|
|
|
let policies = OrgPolicy::find_by_org(&org_id, &conn);
|
|
|
|
|
let policies_json: Vec<Value> = policies.iter().map(OrgPolicy::to_json).collect();
|
|
|
|
|
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Data": policies_json,
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"ContinuationToken": null
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/organizations/<org_id>/policies/token?<token>")]
|
|
|
|
@ -1017,8 +1017,8 @@ fn get_organization_tax(org_id: String, _headers: Headers, _conn: DbConn) -> Emp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/plans")]
|
|
|
|
|
fn get_plans(_headers: Headers, _conn: DbConn) -> JsonResult {
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
fn get_plans(_headers: Headers, _conn: DbConn) -> Json<Value> {
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"Data": [
|
|
|
|
|
{
|
|
|
|
@ -1065,17 +1065,17 @@ fn get_plans(_headers: Headers, _conn: DbConn) -> JsonResult {
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"ContinuationToken": null
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[get("/plans/sales-tax-rates")]
|
|
|
|
|
fn get_plans_tax_rates(_headers: Headers, _conn: DbConn) -> JsonResult {
|
|
|
|
|
fn get_plans_tax_rates(_headers: Headers, _conn: DbConn) -> Json<Value> {
|
|
|
|
|
// Prevent a 404 error, which also causes Javascript errors.
|
|
|
|
|
Ok(Json(json!({
|
|
|
|
|
Json(json!({
|
|
|
|
|
"Object": "list",
|
|
|
|
|
"Data": [],
|
|
|
|
|
"ContinuationToken": null
|
|
|
|
|
})))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
|