From f269fb5cfc367eed3aad0df22f80ec94ce4dbec2 Mon Sep 17 00:00:00 2001 From: Ginger Date: Mon, 27 Apr 2026 16:52:12 -0400 Subject: [PATCH] chore: Clippy fixes --- src/api/client/account/mod.rs | 2 +- src/service/oauth/mod.rs | 3 ++- src/service/uiaa/mod.rs | 6 ++++-- src/web/pages/account/deactivate.rs | 2 -- src/web/pages/account/login.rs | 3 +-- src/web/pages/account/mod.rs | 7 +------ src/web/pages/components/form.rs | 2 +- src/web/pages/components/mod.rs | 8 +++++--- src/web/pages/mod.rs | 1 - .../pages/templates/reset_password_request.html.j2 | 13 ++++++------- 10 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/api/client/account/mod.rs b/src/api/client/account/mod.rs index bd40c3674..a30093356 100644 --- a/src/api/client/account/mod.rs +++ b/src/api/client/account/mod.rs @@ -286,7 +286,7 @@ pub(crate) async fn deactivate_route( // Prompt the user to confirm with their password using UIAA let _ = services .uiaa - .authenticate_password(&body.auth, &sender_user, identity.sender_device(), None) + .authenticate_password(&body.auth, sender_user, identity.sender_device(), None) .await?; // Remove profile pictures and display name diff --git a/src/service/oauth/mod.rs b/src/service/oauth/mod.rs index a75718f9b..9d85623ec 100644 --- a/src/service/oauth/mod.rs +++ b/src/service/oauth/mod.rs @@ -7,7 +7,7 @@ use std::{ use base64::Engine; use conduwuit::{Result, utils::hash::sha256}; use database::{Deserialized, Json, Map}; -use ruma::{DeviceId, OwnedUserId, UserId}; +use ruma::DeviceId; use crate::{Dep, config, oauth::client_metadata::ClientMetadata}; @@ -36,6 +36,7 @@ pub enum OAuthTicket { impl OAuthTicket { const MAX_AGE: Duration = Duration::from_mins(10); + #[must_use] pub fn ticket_issue_path(&self) -> &'static str { match self { | Self::CrossSigningReset => "/account/cross_signing_reset", diff --git a/src/service/uiaa/mod.rs b/src/service/uiaa/mod.rs index 4c86f248d..cb7ced129 100644 --- a/src/service/uiaa/mod.rs +++ b/src/service/uiaa/mod.rs @@ -83,8 +83,8 @@ enum UiaaSessionMetadata { impl UiaaSessionMetadata { fn into_identity(self) -> Identity { match self { - | UiaaSessionMetadata::Legacy { identity } => identity, - | UiaaSessionMetadata::OAuth { localpart, .. } => + | Self::Legacy { identity } => identity, + | Self::OAuth { localpart, .. } => assign!(Identity::default(), { localpart: Some(localpart) }), } } @@ -98,10 +98,12 @@ pub struct UiaaInitiator<'a> { } impl<'a> UiaaInitiator<'a> { + #[must_use] pub fn new(user_id: &'a UserId, device_id: Option<&'a DeviceId>) -> Self { Self { user_id, device_id, oauth_ticket: None } } + #[must_use] pub fn with_oauth_ticket( user_id: &'a UserId, device_id: Option<&'a DeviceId>, diff --git a/src/web/pages/account/deactivate.rs b/src/web/pages/account/deactivate.rs index bf3e5a161..9b2da73d8 100644 --- a/src/web/pages/account/deactivate.rs +++ b/src/web/pages/account/deactivate.rs @@ -1,9 +1,7 @@ use axum::{Router, extract::State, routing::on}; use conduwuit_api::client::full_user_deactivate; -use conduwuit_service::oauth::OAuthTicket; use futures::StreamExt; use ruma::{OwnedRoomId, OwnedUserId, UserId}; -use serde::Deserialize; use tower_sessions::Session; use validator::{Validate, ValidationError, ValidationErrors}; diff --git a/src/web/pages/account/login.rs b/src/web/pages/account/login.rs index e955409fa..d3772aa7d 100644 --- a/src/web/pages/account/login.rs +++ b/src/web/pages/account/login.rs @@ -11,9 +11,8 @@ use ruma::{ OwnedUserId, api::client::uiaa::{EmailUserIdentifier, MatrixUserIdentifier, UserIdentifier}, }; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use tower_sessions::Session; -use validator::Validate; use crate::{ WebError, diff --git a/src/web/pages/account/mod.rs b/src/web/pages/account/mod.rs index 604a2f22c..b670e83f4 100644 --- a/src/web/pages/account/mod.rs +++ b/src/web/pages/account/mod.rs @@ -1,9 +1,4 @@ -use axum::{ - Router, - extract::State, - response::{IntoResponse, Response}, - routing::get, -}; +use axum::{Router, extract::State, response::Response, routing::get}; use conduwuit_service::threepid::EmailRequirement; use futures::StreamExt; use ruma::{OwnedClientSecret, OwnedSessionId}; diff --git a/src/web/pages/components/form.rs b/src/web/pages/components/form.rs index f6be50301..88f915d63 100644 --- a/src/web/pages/components/form.rs +++ b/src/web/pages/components/form.rs @@ -1,5 +1,5 @@ use askama::{Template, filters::HtmlSafe}; -use validator::{ValidationError, ValidationErrors}; +use validator::ValidationErrors; /// A reusable form component with field validation. #[derive(Debug, Template)] diff --git a/src/web/pages/components/mod.rs b/src/web/pages/components/mod.rs index af32d0d69..0c72c31f7 100644 --- a/src/web/pages/components/mod.rs +++ b/src/web/pages/components/mod.rs @@ -116,9 +116,11 @@ impl DeviceCard { let display_name = oauth_metadata .as_ref() .and_then(|metadata| metadata.client_name.clone()) - .or(device - .as_ref() - .and_then(|device| device.display_name.clone())); + .or_else(|| { + device + .as_ref() + .and_then(|device| device.display_name.clone()) + }); let avatar_src = oauth_metadata .as_ref() diff --git a/src/web/pages/mod.rs b/src/web/pages/mod.rs index 922d183e6..fe154b8ab 100644 --- a/src/web/pages/mod.rs +++ b/src/web/pages/mod.rs @@ -35,7 +35,6 @@ macro_rules! template { ) => { #[derive(Debug, askama::Template)] #[template(path = $path)] - #[allow(clippy::useless_let_if_seq)] struct $name$(<$lifetime>)? { context: $crate::pages::TemplateContext, $($field_name: $field_type,)* diff --git a/src/web/pages/templates/reset_password_request.html.j2 b/src/web/pages/templates/reset_password_request.html.j2 index 46993a27f..1e71f33a7 100644 --- a/src/web/pages/templates/reset_password_request.html.j2 +++ b/src/web/pages/templates/reset_password_request.html.j2 @@ -5,13 +5,12 @@ Reset your password {%- endblock -%} {%- block content -%} -{% decl body_class -%} -{% if let ResetPasswordRequestBody::Unavailable = body -%} - {% let body_class = "panel middle" -%} -{% else -%} - {% let body_class = "panel" -%} -{% endif -%} -
+{% match body %} + {% when ResetPasswordRequestBody::Form(_) %} +
+ {% when ResetPasswordRequestBody::Unavailable %} +
+{% endmatch %}

Reset your password

{% match body %} {% when ResetPasswordRequestBody::Form(form) %}