chore: format code

This commit is contained in:
qaz741wsd856 2025-12-29 10:19:39 +00:00
parent 453d24cade
commit fcbfb928f7
4 changed files with 13 additions and 14 deletions

View file

@ -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);

View file

@ -19,9 +19,7 @@ pub async fn now() -> Json<String> {
///
/// Simple healthcheck. Vaultwarden uses this to also verify DB connectivity.
#[worker::send]
pub async fn alive(
State(env): State<Arc<Env>>,
) -> Result<Json<String>, AppError> {
pub async fn alive(State(env): State<Arc<Env>>) -> Result<Json<String>, 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<HibpBreachQuery>) -> Json<Value> {
Json(json!([]))
}

View file

@ -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

View file

@ -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 {