From 3c112897d44c40961b8b24bc565668a45f9a651a Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Mon, 27 May 2024 02:02:06 -0400 Subject: [PATCH] fix: Display a nicer message for failed logins This commit technically closes #41 but the issue is deeper than the message itself. The message `unable to send message: Connection refused (os error 111)` overrides the failed login prompt. `COSMIC greeter` seems to be sending a stray message over the socket. --- i18n/en/cosmic_greeter.ftl | 4 ++++ src/greeter.rs | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/i18n/en/cosmic_greeter.ftl b/i18n/en/cosmic_greeter.ftl index 69385a4..e819fac 100644 --- a/i18n/en/cosmic_greeter.ftl +++ b/i18n/en/cosmic_greeter.ftl @@ -5,3 +5,7 @@ restart-timeout = The system will restart automatically in {$seconds} seconds. shutdown = Shut down shutdown-now = Shut down now? shutdown-timeout = The system will shut down automatically in {$seconds} seconds. + +# Error messages +auth-failed = You entered an invalid password. +try-again = Please try again. diff --git a/src/greeter.rs b/src/greeter.rs index 6a65bf9..882ebd3 100644 --- a/src/greeter.rs +++ b/src/greeter.rs @@ -309,11 +309,17 @@ async fn request_message(socket: Arc, request: Request) -> Message { } }, Response::Error { - error_type: _, + error_type: error, description, } => { - //TODO: use error_type? - return Message::Error(socket, description); + log::error!("{error:?} => {description}"); + return match error { + greetd_ipc::ErrorType::AuthError => Message::Error( + socket, + format!("{} {}", fl!("auth-failed"), fl!("try-again")), + ), + greetd_ipc::ErrorType::Error => Message::Error(socket, description), + }; } Response::Success => match request { Request::CreateSession { .. } => {