mirror of
https://github.com/dani-garcia/bitwarden_rs
synced 2024-11-26 03:49:38 +01:00
Removed unnecessary checks, simplified the code a bit
This commit is contained in:
parent
62be23b1c0
commit
46f3b229ee
@ -193,33 +193,28 @@ 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"),
|
None => err!("Collection not found"),
|
||||||
Some(user_org) => if user_org.has_full_access() {
|
Some(collection) => if collection.org_uuid == org_id {
|
||||||
match Collection::find_by_uuid(&col_id, &conn) {
|
collection
|
||||||
None => err!("Collection not found"),
|
} else {
|
||||||
Some(collection) => if collection.org_uuid == org_id {
|
err!("Collection and Organization id do not match")
|
||||||
match UserOrganization::find_by_uuid(&org_user_id, &conn) {
|
}
|
||||||
None => err!("User not found in organization"),
|
};
|
||||||
Some(user_org) => {
|
|
||||||
match CollectionUser::find_by_collection_and_user(&collection.uuid, &user_org.user_uuid, &conn) {
|
match UserOrganization::find_by_uuid(&org_user_id, &conn) {
|
||||||
None => err!("User not assigned to collection"),
|
None => err!("User not found in organization"),
|
||||||
Some(col_user) => {
|
Some(user_org) => {
|
||||||
match col_user.delete(&conn) {
|
match CollectionUser::find_by_collection_and_user(&collection.uuid, &user_org.user_uuid, &conn) {
|
||||||
Ok(()) => Ok(()),
|
None => err!("User not assigned to collection"),
|
||||||
Err(_) => err!("Failed removing user from collection")
|
Some(col_user) => {
|
||||||
}
|
match col_user.delete(&conn) {
|
||||||
}
|
Ok(()) => Ok(()),
|
||||||
}
|
Err(_) => err!("Failed removing user from collection")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
err!("Collection and Organization id do not match")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
err!("Not enough rights to delete Collection")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user