Skip to content

Commit

Permalink
fix: Display a nicer message for failed logins
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joshuamegnauth54 committed May 27, 2024
1 parent 4613fbb commit 3c11289
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions i18n/en/cosmic_greeter.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
12 changes: 9 additions & 3 deletions src/greeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,17 @@ async fn request_message(socket: Arc<UnixStream>, 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 { .. } => {
Expand Down

0 comments on commit 3c11289

Please sign in to comment.