Removed unnecessary checks, simplified the code a bit

pull/32/head
Miroslav Prasil 7 years ago
parent 62be23b1c0
commit 46f3b229ee

@ -193,13 +193,16 @@ fn post_organization_collection_update(org_id: String, col_id: String, headers:
} }
#[post("/organizations/<org_id>/collections/<col_id>/delete-user/<org_user_id>")] #[post("/organizations/<org_id>/collections/<col_id>/delete-user/<org_user_id>")]
fn post_organization_collection_delete_user(org_id: String, col_id: String, org_user_id: String, headers: Headers, conn: DbConn) -> EmptyResult { fn post_organization_collection_delete_user(org_id: String, col_id: String, org_user_id: String, headers: AdminHeaders, conn: DbConn) -> EmptyResult {
match UserOrganization::find_by_user_and_org(&headers.user.uuid, &org_id, &conn) { let collection = match Collection::find_by_uuid(&col_id, &conn) {
None => err!("Not a member of Organization"),
Some(user_org) => if user_org.has_full_access() {
match Collection::find_by_uuid(&col_id, &conn) {
None => err!("Collection not found"), None => err!("Collection not found"),
Some(collection) => if collection.org_uuid == org_id { Some(collection) => if collection.org_uuid == org_id {
collection
} else {
err!("Collection and Organization id do not match")
}
};
match UserOrganization::find_by_uuid(&org_user_id, &conn) { match UserOrganization::find_by_uuid(&org_user_id, &conn) {
None => err!("User not found in organization"), None => err!("User not found in organization"),
Some(user_org) => { Some(user_org) => {
@ -214,14 +217,6 @@ fn post_organization_collection_delete_user(org_id: String, col_id: String, org_
} }
} }
} }
} else {
err!("Collection and Organization id do not match")
}
}
} else {
err!("Not enough rights to delete Collection")
}
}
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]

Loading…
Cancel
Save