Fix cargo clippy issues
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -21,7 +21,7 @@ where
|
|||||||
if POSTGRES_CONNECTION.with(|i| i.borrow().is_none()) {
|
if POSTGRES_CONNECTION.with(|i| i.borrow().is_none()) {
|
||||||
let database_url = AppConfig::get().db_connection_chain();
|
let database_url = AppConfig::get().db_connection_chain();
|
||||||
let conn = PgConnection::establish(&database_url)
|
let conn = PgConnection::establish(&database_url)
|
||||||
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url));
|
.unwrap_or_else(|_| panic!("Error connecting to {database_url}"));
|
||||||
|
|
||||||
POSTGRES_CONNECTION.with(|i| *i.borrow_mut() = Some(conn))
|
POSTGRES_CONNECTION.with(|i| *i.borrow_mut() = Some(conn))
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ where
|
|||||||
POSTGRES_CONNECTION.with(|i| *i.borrow_mut() = None)
|
POSTGRES_CONNECTION.with(|i| *i.borrow_mut() = None)
|
||||||
}
|
}
|
||||||
|
|
||||||
log::error!("Database query error! {:?}", e);
|
log::error!("Database query error! {e:?}");
|
||||||
Err(e.into())
|
Err(e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ pub async fn create_bucket_if_required() -> anyhow::Result<()> {
|
|||||||
log::warn!("The bucket does not seem to exists, trying to create it!")
|
log::warn!("The bucket does not seem to exists, trying to create it!")
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Got unexpected error when querying bucket info: {}", e);
|
log::error!("Got unexpected error when querying bucket info: {e}");
|
||||||
return Err(BucketServiceError::FailedFetchBucketInfo.into());
|
return Err(BucketServiceError::FailedFetchBucketInfo.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,7 @@ pub async fn request_reset_password(
|
|||||||
match users_service::get_by_mail(&req.mail).await {
|
match users_service::get_by_mail(&req.mail).await {
|
||||||
Ok(mut user) => users_service::request_reset_password(&mut user).await?,
|
Ok(mut user) => users_service::request_reset_password(&mut user).await?,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(
|
log::error!("Could not locate user account {e}! (error silently ignored)");
|
||||||
"Could not locate user account {}! (error silently ignored)",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +119,7 @@ pub async fn check_reset_password_token(
|
|||||||
RatedAction::CheckResetPasswordTokenFailed,
|
RatedAction::CheckResetPasswordTokenFailed,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
log::error!("Password reset token could not be used: {}", e);
|
log::error!("Password reset token could not be used: {e}");
|
||||||
return Ok(HttpResponse::NotFound().finish());
|
return Ok(HttpResponse::NotFound().finish());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -156,7 +153,7 @@ pub async fn reset_password(remote_ip: RemoteIP, req: web::Json<ResetPasswordBod
|
|||||||
RatedAction::CheckResetPasswordTokenFailed,
|
RatedAction::CheckResetPasswordTokenFailed,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
log::error!("Password reset token could not be used: {}", e);
|
log::error!("Password reset token could not be used: {e}");
|
||||||
return Ok(HttpResponse::NotFound().finish());
|
return Ok(HttpResponse::NotFound().finish());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -196,7 +193,7 @@ pub async fn password_login(remote_ip: RemoteIP, req: web::Json<PasswordLoginQue
|
|||||||
let user = match users_service::get_by_mail(&req.mail).await {
|
let user = match users_service::get_by_mail(&req.mail).await {
|
||||||
Ok(u) => u,
|
Ok(u) => u,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Auth failed: could not find account by mail! {}", e);
|
log::error!("Auth failed: could not find account by mail! {e}");
|
||||||
rate_limiter_service::record_action(remote_ip.0, RatedAction::FailedPasswordLogin)
|
rate_limiter_service::record_action(remote_ip.0, RatedAction::FailedPasswordLogin)
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(HttpResponse::Unauthorized().json("Invalid credentials"));
|
return Ok(HttpResponse::Unauthorized().json("Invalid credentials"));
|
||||||
|
@ -183,9 +183,9 @@ pub async fn import_family(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = req_member_data.to_member(member).await {
|
if let Err(e) = req_member_data.to_member(member).await {
|
||||||
log::error!("Error while processing import (member {:?}) - {e}", req_id);
|
log::error!("Error while processing import (member {req_id:?}) - {e}");
|
||||||
return Ok(
|
return Ok(
|
||||||
HttpResponse::BadRequest().json(format!("Failed to validate member {:?}!", req_id))
|
HttpResponse::BadRequest().json(format!("Failed to validate member {req_id:?}!"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ impl Display for HttpErr {
|
|||||||
|
|
||||||
impl actix_web::error::ResponseError for HttpErr {
|
impl actix_web::error::ResponseError for HttpErr {
|
||||||
fn error_response(&self) -> HttpResponse<BoxBody> {
|
fn error_response(&self) -> HttpResponse<BoxBody> {
|
||||||
log::error!("Error while processing request! {}", self);
|
log::error!("Error while processing request! {self}");
|
||||||
HttpResponse::InternalServerError().body("Failed to execute request!")
|
HttpResponse::InternalServerError().body("Failed to execute request!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ impl FromRequest for FamilyAndAccommodationInPath {
|
|||||||
Self::load_accommodation_from_path(family, accommodation_id)
|
Self::load_accommodation_from_path(family, accommodation_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to extract accommodation ID from URL! {}", e);
|
log::error!("Failed to extract accommodation ID from URL! {e}");
|
||||||
actix_web::error::ErrorNotFound("Could not fetch accommodation information!")
|
actix_web::error::ErrorNotFound("Could not fetch accommodation information!")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -85,7 +85,7 @@ impl FromRequest for FamilyAndAccommodationReservationCalendarInPath {
|
|||||||
Self::load_calendar_from_path(family, accommodation_id)
|
Self::load_calendar_from_path(family, accommodation_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to extract calendar ID from URL! {}", e);
|
log::error!("Failed to extract calendar ID from URL! {e}");
|
||||||
actix_web::error::ErrorNotFound("Could not fetch calendar information!")
|
actix_web::error::ErrorNotFound("Could not fetch calendar information!")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -95,7 +95,7 @@ impl FromRequest for FamilyAndAccommodationReservationInPath {
|
|||||||
Self::load_accommodation_reservation_from_path(family, reservation_id)
|
Self::load_accommodation_reservation_from_path(family, reservation_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to extract accommodation ID from URL! {}", e);
|
log::error!("Failed to extract accommodation ID from URL! {e}");
|
||||||
actix_web::error::ErrorNotFound("Could not fetch accommodation information!")
|
actix_web::error::ErrorNotFound("Could not fetch accommodation information!")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -71,7 +71,7 @@ impl FromRequest for FamilyAndCoupleInPath {
|
|||||||
FamilyAndCoupleInPath::load_couple_from_path(family, couple_id)
|
FamilyAndCoupleInPath::load_couple_from_path(family, couple_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to extract couple ID from URL! {}", e);
|
log::error!("Failed to extract couple ID from URL! {e}");
|
||||||
actix_web::error::ErrorNotFound("Could not fetch couple information!")
|
actix_web::error::ErrorNotFound("Could not fetch couple information!")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -62,7 +62,7 @@ impl FromRequest for FamilyInPath {
|
|||||||
FamilyInPath::load_family_from_path(&token, family_id)
|
FamilyInPath::load_family_from_path(&token, family_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to extract family ID from URL! {}", e);
|
log::error!("Failed to extract family ID from URL! {e}");
|
||||||
actix_web::error::ErrorNotFound("Could not fetch family information!")
|
actix_web::error::ErrorNotFound("Could not fetch family information!")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -71,7 +71,7 @@ impl FromRequest for FamilyAndMemberInPath {
|
|||||||
FamilyAndMemberInPath::load_member_from_path(family, member_id)
|
FamilyAndMemberInPath::load_member_from_path(family, member_id)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!("Failed to extract member ID from URL! {}", e);
|
log::error!("Failed to extract member ID from URL! {e}");
|
||||||
actix_web::error::ErrorNotFound("Could not fetch member information!")
|
actix_web::error::ErrorNotFound("Could not fetch member information!")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -43,7 +43,7 @@ impl User {
|
|||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|hash| {
|
.map(|hash| {
|
||||||
bcrypt::verify(password, hash).unwrap_or_else(|e| {
|
bcrypt::verify(password, hash).unwrap_or_else(|e| {
|
||||||
log::error!("Failed to validate password! {}", e);
|
log::error!("Failed to validate password! {e}");
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -125,13 +125,13 @@ async fn load_token_info(token: &LoginTokenValue) -> anyhow::Result<Option<Login
|
|||||||
let token = match user_tokens.iter_mut().find(|t| t.key == key) {
|
let token = match user_tokens.iter_mut().find(|t| t.key == key) {
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
None => {
|
None => {
|
||||||
log::error!("Could not find token for key '{}' (missing token)", key);
|
log::error!("Could not find token for key '{key}' (missing token)");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if token.is_expired() {
|
if token.is_expired() {
|
||||||
log::error!("Could not find token for key '{}' (token expired)", key);
|
log::error!("Could not find token for key '{key}' (token expired)");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ impl FromRequest for LoginToken {
|
|||||||
|
|
||||||
let token = match load_token_info(&token).await {
|
let token = match load_token_info(&token).await {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to load auth token! {}", e);
|
log::error!("Failed to load auth token! {e}");
|
||||||
return Err(actix_web::error::ErrorPreconditionFailed(
|
return Err(actix_web::error::ErrorPreconditionFailed(
|
||||||
"Failed to check auth token!",
|
"Failed to check auth token!",
|
||||||
));
|
));
|
||||||
|
@ -27,7 +27,7 @@ pub async fn send_mail<D: Display>(to: &str, subject: &str, body: D) -> anyhow::
|
|||||||
let mailer = mailer.build();
|
let mailer = mailer.build();
|
||||||
|
|
||||||
mailer.send(&email)?;
|
mailer.send(&email)?;
|
||||||
log::debug!("A mail was sent to {} (subject = {})", to, subject);
|
log::debug!("A mail was sent to {to} (subject = {subject})");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ pub mod loop_detection {
|
|||||||
None => false,
|
None => false,
|
||||||
Some(id) => {
|
Some(id) => {
|
||||||
if curr_stack.contains(id) {
|
if curr_stack.contains(id) {
|
||||||
log::debug!("Loop detected! {:?}", curr_stack);
|
log::debug!("Loop detected! {curr_stack:?}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ pub fn sha256(bytes: &[u8]) -> String {
|
|||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update(bytes);
|
hasher.update(bytes);
|
||||||
let h = hasher.finalize();
|
let h = hasher.finalize();
|
||||||
format!("{:x}", h)
|
format!("{h:x}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute hash of a slice of bytes (sha512)
|
/// Compute hash of a slice of bytes (sha512)
|
||||||
@ -13,5 +13,5 @@ pub fn sha512(bytes: &[u8]) -> String {
|
|||||||
let mut hasher = Sha512::new();
|
let mut hasher = Sha512::new();
|
||||||
hasher.update(bytes);
|
hasher.update(bytes);
|
||||||
let h = hasher.finalize();
|
let h = hasher.finalize();
|
||||||
format!("{:x}", h)
|
format!("{h:x}")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user