forked from lavina/lavina
1
0
Fork 0

keep todos for uncertain behaviour

This commit is contained in:
G1ng3r 2024-02-05 21:03:45 +03:00
parent d6da40e4ff
commit bb09e8bb21
1 changed files with 33 additions and 20 deletions

View File

@ -181,17 +181,17 @@ async fn handle_registration<'a>(
}
CapabilitySubcommand::End => {
let Some((ref username, ref realname)) = future_username else {
break Err(anyhow::Error::msg("Protocol violated"));
todo!();
};
let Some(nickname) = future_nickname.clone() else {
break Err(anyhow::Error::msg("Protocol violated"));
todo!();
};
let username = username.clone();
let realname = realname.clone();
let candidate_user = RegisteredUser {
nickname: nickname.clone(),
username,
realname
realname,
};
if enabled_capabilities.contains(Capabilities::Sasl)
&& validated_user.as_ref() == Some(&candidate_user.nickname)
@ -202,8 +202,10 @@ async fn handle_registration<'a>(
sasl_fail_message(
config.server_name.clone(),
nickname.clone(),
"User credentials was not provided".into()
).write_async(writer).await?;
"User credentials was not provided".into(),
)
.write_async(writer)
.await?;
writer.flush().await?;
continue;
};
@ -225,8 +227,10 @@ async fn handle_registration<'a>(
sasl_fail_message(
config.server_name.clone(),
nickname.clone(),
"User credentials was not provided".into()
).write_async(writer).await?;
"User credentials was not provided".into(),
)
.write_async(writer)
.await?;
writer.flush().await?;
continue;
};
@ -249,8 +253,10 @@ async fn handle_registration<'a>(
sasl_fail_message(
config.server_name.clone(),
nickname.clone(),
"User credentials was not provided".into()
).write_async(writer).await?;
"User credentials was not provided".into(),
)
.write_async(writer)
.await?;
writer.flush().await?;
continue;
};
@ -276,7 +282,13 @@ async fn handle_registration<'a>(
writer.flush().await?;
} else {
if let Some(nickname) = future_nickname.clone() {
sasl_fail_message(config.server_name.clone(), nickname.clone(), "Unsupported mechanism".into()).write_async(writer).await?;
sasl_fail_message(
config.server_name.clone(),
nickname.clone(),
"Unsupported mechanism".into(),
)
.write_async(writer)
.await?;
writer.flush().await?;
} else {
break Err(anyhow::Error::msg("Wrong authentication sequence"));
@ -287,10 +299,11 @@ async fn handle_registration<'a>(
if let Err(e) = auth_user(storage, &body.login, &body.password).await {
tracing::warn!("Authentication failed: {:?}", e);
if let Some(nickname) = future_nickname.clone() {
sasl_fail_message(config.server_name.clone(), nickname.clone(), "Bad credentials".into()).write_async(writer).await?;
sasl_fail_message(config.server_name.clone(), nickname.clone(), "Bad credentials".into())
.write_async(writer)
.await?;
writer.flush().await?;
} else {
}
} else {
let login: Str = body.login.into();
@ -335,7 +348,7 @@ fn sasl_fail_message(sender: Str, nick: Str, text: Str) -> ServerMessage {
ServerMessage {
tags: vec![],
sender: Some(sender),
body: ServerMessageBody::N904SaslFail { nick, text }
body: ServerMessageBody::N904SaslFail { nick, text },
}
}