Skip to content

Commit 3c11289

Browse files
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.
1 parent 4613fbb commit 3c11289

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

i18n/en/cosmic_greeter.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ restart-timeout = The system will restart automatically in {$seconds} seconds.
55
shutdown = Shut down
66
shutdown-now = Shut down now?
77
shutdown-timeout = The system will shut down automatically in {$seconds} seconds.
8+
9+
# Error messages
10+
auth-failed = You entered an invalid password.
11+
try-again = Please try again.

src/greeter.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,17 @@ async fn request_message(socket: Arc<UnixStream>, request: Request) -> Message {
309309
}
310310
},
311311
Response::Error {
312-
error_type: _,
312+
error_type: error,
313313
description,
314314
} => {
315-
//TODO: use error_type?
316-
return Message::Error(socket, description);
315+
log::error!("{error:?} => {description}");
316+
return match error {
317+
greetd_ipc::ErrorType::AuthError => Message::Error(
318+
socket,
319+
format!("{} {}", fl!("auth-failed"), fl!("try-again")),
320+
),
321+
greetd_ipc::ErrorType::Error => Message::Error(socket, description),
322+
};
317323
}
318324
Response::Success => match request {
319325
Request::CreateSession { .. } => {

0 commit comments

Comments
 (0)