aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin.rs
diff options
context:
space:
mode:
authorMathijs van Veluw <[email protected]>2024-12-14 00:55:34 +0100
committerGitHub <[email protected]>2024-12-14 00:55:34 +0100
commit9cd400db6c5da858a4f49eb883469cbd6cb7337d (patch)
tree1c1d1900c1e1ba20da64e4c2052285b2d81317e8 /src/api/admin.rs
parentfd512300448995735961cbeedcbe4b684be1c5fd (diff)
downloadvaultwarden-9cd400db6c5da858a4f49eb883469cbd6cb7337d.tar.gz
vaultwarden-9cd400db6c5da858a4f49eb883469cbd6cb7337d.zip
Some refactoring and optimizations (#5291)
- Refactored several code to use more modern syntax - Made some checks a bit more strict - Updated crates Signed-off-by: BlackDex <[email protected]>
Diffstat (limited to 'src/api/admin.rs')
-rw-r--r--src/api/admin.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/api/admin.rs b/src/api/admin.rs
index 45eb5972..f49f6ed3 100644
--- a/src/api/admin.rs
+++ b/src/api/admin.rs
@@ -495,11 +495,11 @@ struct UserOrgTypeData {
async fn update_user_org_type(data: Json<UserOrgTypeData>, token: AdminToken, mut conn: DbConn) -> EmptyResult {
let data: UserOrgTypeData = data.into_inner();
- let mut user_to_edit =
- match UserOrganization::find_by_user_and_org(&data.user_uuid, &data.org_uuid, &mut conn).await {
- Some(user) => user,
- None => err!("The specified user isn't member of the organization"),
- };
+ let Some(mut user_to_edit) =
+ UserOrganization::find_by_user_and_org(&data.user_uuid, &data.org_uuid, &mut conn).await
+ else {
+ err!("The specified user isn't member of the organization")
+ };
let new_type = match UserOrgType::from_str(&data.user_type.into_string()) {
Some(new_type) => new_type as i32,
@@ -602,9 +602,8 @@ async fn get_json_api<T: DeserializeOwned>(url: &str) -> Result<T, Error> {
}
async fn has_http_access() -> bool {
- let req = match make_http_request(Method::HEAD, "https://github.com/dani-garcia/vaultwarden") {
- Ok(r) => r,
- Err(_) => return false,
+ let Ok(req) = make_http_request(Method::HEAD, "https://github.com/dani-garcia/vaultwarden") else {
+ return false;
};
match req.send().await {
Ok(r) => r.status().is_success(),