From 511f35bcd6fc181b5db9e62dfcc96923285d5343 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 8 Jan 2023 19:34:24 +0000 Subject: [PATCH] Send LOGGEDIN message to the user after authentication --- src/connection.rs | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index 774ba76..6817b0d 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -235,9 +235,9 @@ async fn start_authenticate_flow( }; if authenticated { - write - .send(SaslSuccess(connection.nick.to_string()).into_message()) - .await?; + for message in SaslSuccess(connection.clone()).into_messages() { + write.send(message).await?; + } return Ok(true); } @@ -385,19 +385,37 @@ impl SaslStrategyUnsupported { } /// Returned to the client when authentication is successful. -pub struct SaslSuccess(String); +pub struct SaslSuccess(InitiatedConnection); impl SaslSuccess { #[must_use] - pub fn into_message(self) -> Message { - Message { - tags: None, - prefix: None, - command: Command::Response( - Response::RPL_SASLSUCCESS, - vec![self.0, "SASL authentication successful".to_string()], - ), - } + pub fn into_messages(self) -> [Message; 2] { + [ + Message { + tags: None, + prefix: None, + command: Command::Response( + Response::RPL_SASLSUCCESS, + vec![ + self.0.nick.to_string(), + "SASL authentication successful".to_string(), + ], + ), + }, + Message { + tags: None, + prefix: None, + command: Command::Response( + Response::RPL_LOGGEDIN, + vec![ + self.0.nick.to_string(), + self.0.to_nick().to_string(), + self.0.user.to_string(), + format!("You are now logged in as {}", self.0.user), + ], + ), + }, + ] } } -- libgit2 1.7.2