mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:47:34 +00:00
LoginServer: Add a label for login fail messages
This commit is contained in:
parent
39a5076f40
commit
9246ad96b3
4 changed files with 21 additions and 0 deletions
|
@ -36,4 +36,13 @@ LoginWindow::LoginWindow(GUI::Window* parent)
|
|||
on_submit();
|
||||
};
|
||||
m_log_in_button->set_default(true);
|
||||
|
||||
m_fail_message = *widget.find_descendant_of_type_named<GUI::Label>("fail_message");
|
||||
m_username->on_change = [&] {
|
||||
m_fail_message->set_text("");
|
||||
};
|
||||
m_password->on_change = [&] {
|
||||
if (!m_password->text().is_empty())
|
||||
m_fail_message->set_text("");
|
||||
};
|
||||
}
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {}
|
||||
|
||||
@GUI::Label {
|
||||
name: "fail_message"
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
|
||||
@GUI::Widget {}
|
||||
|
||||
@GUI::Button {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/ImageWidget.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
||||
|
@ -25,11 +26,14 @@ public:
|
|||
String password() const { return m_password->text(); }
|
||||
void set_password(StringView password) { m_password->set_text(password); }
|
||||
|
||||
void set_fail_message(StringView message) { m_fail_message->set_text(message); }
|
||||
|
||||
private:
|
||||
LoginWindow(GUI::Window* parent = nullptr);
|
||||
|
||||
RefPtr<GUI::ImageWidget> m_banner;
|
||||
RefPtr<GUI::TextBox> m_username;
|
||||
RefPtr<GUI::PasswordBox> m_password;
|
||||
RefPtr<GUI::Label> m_fail_message;
|
||||
RefPtr<GUI::Button> m_log_in_button;
|
||||
};
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <Services/LoginServer/LoginWindow.h>
|
||||
#include <errno.h>
|
||||
|
@ -73,11 +74,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto account = Core::Account::from_name(username.characters());
|
||||
if (account.is_error()) {
|
||||
window->set_fail_message(String::formatted("Can't log in: {}.", account.error()));
|
||||
dbgln("failed graphical login for user {}: {}", username, account.error());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!account.value().authenticate(password)) {
|
||||
window->set_fail_message("Can't log in: invalid password.");
|
||||
dbgln("failed graphical login for user {}: invalid password", username);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue