fix(clippy): few refactors

This commit is contained in:
Raphael Roumezin 2026-06-27 16:55:05 +02:00
parent 05c9af4d1e
commit 3b669264bb
No known key found for this signature in database
GPG Key ID: 91D7A94FE35B7922
2 changed files with 19 additions and 20 deletions

View File

@ -135,43 +135,43 @@ async fn post_webauthn_attestation_options(
challenge.public_key.pub_key_cred_params = vec![
PubKeyCredParams {
alg: COSEAlgorithm::ES256 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::ES384 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::ES512 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::RS256 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::RS384 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::RS512 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::PS256 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::PS384 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::PS512 as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
PubKeyCredParams {
alg: COSEAlgorithm::EDDSA as i64,
type_: "public-key".to_string(),
type_: "public-key".to_owned(),
},
];
@ -216,13 +216,12 @@ async fn post_webauthn(
// Retrieve and delete the saved challenge state from the database
let type_ = TwoFactorType::WebauthnPasskeyRegisterChallenge as i32;
let credential = match TwoFactor::find_by_user_and_type(&user.uuid, type_, &conn).await {
Some(tf) => {
let state: PasskeyRegistration = serde_json::from_str(&tf.data)?;
tf.delete(&conn).await?;
WEBAUTHN_PASSWORDLESS.finish_passkey_registration(&data.device_response.into(), &state)?
}
None => err!("No registration challenge found. Please try again."),
let credential = if let Some(tf) = TwoFactor::find_by_user_and_type(&user.uuid, type_, &conn).await {
let state: PasskeyRegistration = serde_json::from_str(&tf.data)?;
tf.delete(&conn).await?;
WEBAUTHN_PASSWORDLESS.finish_passkey_registration(&data.device_response.into(), &state)?
} else {
err!("No registration challenge found. Please try again.")
};
WebauthnCredential::new(
@ -256,7 +255,7 @@ async fn post_webauthn_delete(
data.validate(&user, false, &conn).await?;
WebauthnCredential::delete_by_uuid_and_user(&WebauthnCredentialId::from(uuid.to_string()), &user.uuid, &conn)
WebauthnCredential::delete_by_uuid_and_user(&WebauthnCredentialId::from(uuid.to_owned()), &user.uuid, &conn)
.await?;
Ok(Status::Ok)

View File

@ -581,12 +581,12 @@ async fn webauthn_login(data: ConnectData, user_id: &mut Option<UserId>, conn: &
raw_state.get_mut("ast").and_then(|v| v.get_mut("credentials")).and_then(|v| v.as_array_mut())
{
credentials.clear();
for (_, passkey) in user_webauthn_credentials.iter() {
for (_, passkey) in &user_webauthn_credentials {
let passkey_owned: Passkey = passkey.clone();
let cred = <webauthn_rs::prelude::Credential>::from(passkey_owned);
credentials.push(serde_json::to_value(&cred)?);
}
};
}
serde_json::from_value(raw_state)?
} else {
err!(