Skip to content

Commit

Permalink
cargo fmt/clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Myers <[email protected]>
  • Loading branch information
Elizafox committed Apr 1, 2024
1 parent 57f8267 commit fe249ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn validate_url(url: &str) -> Result<(), ValidationError> {
}
}
}
_ => Err(err.clone().with_message("Bad URL scheme".into())),
_ => Err(err.with_message("Bad URL scheme".into())),
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/web/admin/cidr_ban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,17 @@ mod post {
.field_errors()
.get("range")
.map_or("Unknown error".to_string(), |v| v[0].to_string());
debug!("Invalid range ({}) submitted from user {}: {error_reason}", ban_form.range, user.0.username);
debug!(
"Invalid range ({}) submitted from user {}: {error_reason}",
ban_form.range, user.0.username
);
messages.error(format!("Invalid range: {error_reason}").as_str());
return Ok(Redirect::to("/admin/cidr_bans").into_response());
}

let network = match IpNetwork::from_str(&ban_form.range) {
Ok(network) => network,
Err(_) => unreachable!(),
};
// Validated previously
let network =
IpNetwork::from_str(&ban_form.range).map_or_else(|_| unreachable!(), |network| network);

// Invalidate so users who aren't banned will now be
state.bancache.invalidate(network);
Expand Down

0 comments on commit fe249ad

Please sign in to comment.