From fcbfb928f78fc88bba2db68161f3222b26b2d5fb Mon Sep 17 00:00:00 2001 From: qaz741wsd856 Date: Mon, 29 Dec 2025 10:19:39 +0000 Subject: [PATCH] chore: format code --- src/handlers/identity.rs | 11 +++++++---- src/handlers/meta.rs | 6 +----- src/handlers/twofactor.rs | 6 +++--- src/router.rs | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/handlers/identity.rs b/src/handlers/identity.rs index 4d086e0..17e1cdf 100644 --- a/src/handlers/identity.rs +++ b/src/handlers/identity.rs @@ -12,8 +12,7 @@ use crate::{ db, error::AppError, handlers::{ - allow_totp_drift, - server_password_iterations, + allow_totp_drift, server_password_iterations, twofactor::{is_twofactor_enabled, list_user_twofactors}, }, models::twofactor::{RememberTokenData, TwoFactor, TwoFactorType}, @@ -267,7 +266,9 @@ pub async fn token( Some(code) => code, None => { // Return 2FA required error - return Err(AppError::TwoFactorRequired(json_err_twofactor(&twofactor_ids))); + return Err(AppError::TwoFactorRequired(json_err_twofactor( + &twofactor_ids, + ))); } }; @@ -278,7 +279,9 @@ pub async fn token( .find(|tf| { tf.enabled && tf.atype == TwoFactorType::Authenticator as i32 }) - .ok_or_else(|| AppError::BadRequest("TOTP not configured".to_string()))?; + .ok_or_else(|| { + AppError::BadRequest("TOTP not configured".to_string()) + })?; // Validate TOTP code let allow_drift = allow_totp_drift(&env); diff --git a/src/handlers/meta.rs b/src/handlers/meta.rs index f1a4f9b..54684c1 100644 --- a/src/handlers/meta.rs +++ b/src/handlers/meta.rs @@ -19,9 +19,7 @@ pub async fn now() -> Json { /// /// Simple healthcheck. Vaultwarden uses this to also verify DB connectivity. #[worker::send] -pub async fn alive( - State(env): State>, -) -> Result, AppError> { +pub async fn alive(State(env): State>) -> Result, AppError> { // Verify D1 binding is present + basic query works. let db = db::get_db(&env)?; db.prepare("SELECT 1 as ok") @@ -54,5 +52,3 @@ pub struct HibpBreachQuery { pub async fn hibp_breach(_query: axum::extract::Query) -> Json { Json(json!([])) } - - diff --git a/src/handlers/twofactor.rs b/src/handlers/twofactor.rs index 862261a..4030d07 100644 --- a/src/handlers/twofactor.rs +++ b/src/handlers/twofactor.rs @@ -35,9 +35,9 @@ pub(crate) async fn list_user_twofactors( /// For now, we intentionally only treat Authenticator (TOTP) as a real 2FA provider. /// Remember-device tokens are never considered a 2FA method by themselves. pub(crate) fn is_twofactor_enabled(twofactors: &[TwoFactor]) -> bool { - twofactors.iter().any(|tf| { - tf.enabled && tf.atype == TwoFactorType::Authenticator as i32 - }) + twofactors + .iter() + .any(|tf| tf.enabled && tf.atype == TwoFactorType::Authenticator as i32) } /// GET /api/two-factor - Get all enabled 2FA providers for current user diff --git a/src/router.rs b/src/router.rs index ccddb58..6b98f25 100644 --- a/src/router.rs +++ b/src/router.rs @@ -6,8 +6,8 @@ use std::sync::Arc; use worker::Env; use crate::handlers::{ - accounts, attachments, ciphers, config, devices, domains, emergency_access, folders, identity, import, - meta, sync, twofactor, webauth, + accounts, attachments, ciphers, config, devices, domains, emergency_access, folders, identity, + import, meta, sync, twofactor, webauth, }; pub fn api_router(env: Env) -> Router {