Skip to content

Commit

Permalink
clippy: Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsJamie9494 committed Sep 1, 2024
1 parent 52780a8 commit 1ec6bc2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/api/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ fn get_filter_string(filter: &str, filter_added: &mut bool) -> String {
let mut filter_string: String;

if *filter_added {
filter_string = String::from(format!(" OR {filter} "));
filter_string = format!(" OR {filter} ");
} else {
filter_string = String::from(format!(" WHERE {filter} "));
filter_string = format!(" WHERE {filter} ");
*filter_added = true;
}

Expand Down
11 changes: 3 additions & 8 deletions src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ lazy_static::lazy_static! {
pub static ref JWT_KEY: HS256Key = HS256Key::from_bytes(&STANDARD_NO_PAD.decode(std::env::var("JWT_KEY").unwrap()).unwrap());
}

pub struct ApiAuth {
pub token: String,
}
pub struct ApiAuth {}

#[derive(Serialize, Deserialize)]

pub struct CustomClaims {
// Admin is the only supported scope
scopes: Vec<String>,
Expand Down Expand Up @@ -65,14 +64,10 @@ impl<'r> FromRequest<'r> for ApiAuth {
let options = VerificationOptions::default();
if let Ok(claims) = JWT_KEY.verify_token::<CustomClaims>(token, Some(options)) {
return match claims.custom.scopes.contains(&"admin".to_string()) {
true => request::Outcome::Success(ApiAuth {
token: token.to_string(),
}),
true => request::Outcome::Success(ApiAuth {}),
false => request::Outcome::Error((Status::Forbidden, ApiError::NoAdminScope)),
};
};

return request::Outcome::Error((Status::Forbidden, ApiError::NoAdminScope));
}
request::Outcome::Error((Status::Forbidden, ApiError::Nil))
}
Expand Down
2 changes: 1 addition & 1 deletion src/database/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'r, D: Database> FromRequest<'r> for Reloader<D> {
}
}

impl<'a, D: Database> Sentinel for Reloader<D> {
impl<D: Database> Sentinel for Reloader<D> {
fn abort(rocket: &Rocket<Ignite>) -> bool {
D::fetch(rocket).is_none()
}
Expand Down

0 comments on commit 1ec6bc2

Please sign in to comment.