refactor: use let-else in *-request-with-auth handler

This commit is contained in:
link2xt
2023-12-06 19:55:25 +00:00
parent b9ff8b1d6c
commit 35c5f42b35

View File

@@ -384,20 +384,17 @@ pub(crate) async fn handle_securejoin_handshake(
} }
info!(context, "Fingerprint verified.",); info!(context, "Fingerprint verified.",);
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code // verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
let auth_0 = match mime_message.get_header(HeaderDef::SecureJoinAuth) { let Some(auth) = mime_message.get_header(HeaderDef::SecureJoinAuth) else {
Some(auth) => auth, could_not_establish_secure_connection(
None => { context,
could_not_establish_secure_connection( contact_id,
context, info_chat_id(context, contact_id).await?,
contact_id, "Auth not provided.",
info_chat_id(context, contact_id).await?, )
"Auth not provided.", .await?;
) return Ok(HandshakeMessage::Ignore);
.await?;
return Ok(HandshakeMessage::Ignore);
}
}; };
if !token::exists(context, token::Namespace::Auth, auth_0).await { if !token::exists(context, token::Namespace::Auth, auth).await {
could_not_establish_secure_connection( could_not_establish_secure_connection(
context, context,
contact_id, contact_id,