diff --git a/src/channels/irc.rs b/src/channels/irc.rs index d53ca25..d63ad41 100644 --- a/src/channels/irc.rs +++ b/src/channels/irc.rs @@ -453,13 +453,22 @@ impl Channel for IrcChannel { "AUTHENTICATE" => { // Server sends "AUTHENTICATE +" to request credentials if sasl_pending && msg.params.first().is_some_and(|p| p == "+") { - let encoded = encode_sasl_plain( - ¤t_nick, - self.sasl_password.as_deref().unwrap_or(""), - ); - let mut guard = self.writer.lock().await; - if let Some(ref mut w) = *guard { - Self::send_raw(w, &format!("AUTHENTICATE {encoded}")).await?; + if let Some(password) = self.sasl_password.as_deref() { + let encoded = encode_sasl_plain(¤t_nick, password); + let mut guard = self.writer.lock().await; + if let Some(ref mut w) = *guard { + Self::send_raw(w, &format!("AUTHENTICATE {encoded}")).await?; + } + } else { + // SASL was requested but no password is configured; abort SASL + tracing::warn!( + "SASL authentication requested but no SASL password is configured; aborting SASL" + ); + sasl_pending = false; + let mut guard = self.writer.lock().await; + if let Some(ref mut w) = *guard { + Self::send_raw(w, "CAP END").await?; + } } } }