mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Use Matrix ID for login
This commit is contained in:
parent
87ecb28558
commit
0f3cffcfd9
3 changed files with 14 additions and 14 deletions
|
@ -73,7 +73,7 @@ private:
|
||||||
QHBoxLayout *form_wrapper_;
|
QHBoxLayout *form_wrapper_;
|
||||||
QVBoxLayout *form_layout_;
|
QVBoxLayout *form_layout_;
|
||||||
|
|
||||||
TextField *username_input_;
|
TextField *matrixid_input_;
|
||||||
TextField *password_input_;
|
TextField *password_input_;
|
||||||
|
|
||||||
InputValidator *matrix_id_validator_;
|
InputValidator *matrix_id_validator_;
|
||||||
|
|
|
@ -17,9 +17,8 @@
|
||||||
|
|
||||||
#include "InputValidator.h"
|
#include "InputValidator.h"
|
||||||
|
|
||||||
// FIXME: Maybe change the regex to match the real Matrix ID format and not email.
|
|
||||||
InputValidator::InputValidator(QObject *parent)
|
InputValidator::InputValidator(QObject *parent)
|
||||||
: matrix_id_("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}")
|
: matrix_id_("@[A-Za-z0-9._%+-]+:[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}")
|
||||||
, matrix_localpart_("[A-za-z0-9._%+-]{3,}")
|
, matrix_localpart_("[A-za-z0-9._%+-]{3,}")
|
||||||
, matrix_password_(".{8,}")
|
, matrix_password_(".{8,}")
|
||||||
, server_domain_("(?!\\-)(?:[a-zA-Z\\d\\-]{0,62}[a-zA-Z\\d]\\.){1,126}(?!\\d+)[a-zA-Z\\d]{1,63}")
|
, server_domain_("(?!\\-)(?:[a-zA-Z\\d\\-]{0,62}[a-zA-Z\\d]\\.){1,126}(?!\\d+)[a-zA-Z\\d]{1,63}")
|
||||||
|
|
|
@ -62,10 +62,11 @@ LoginPage::LoginPage(QWidget *parent)
|
||||||
form_wrapper_->addWidget(form_widget_);
|
form_wrapper_->addWidget(form_widget_);
|
||||||
form_wrapper_->addStretch(1);
|
form_wrapper_->addStretch(1);
|
||||||
|
|
||||||
username_input_ = new TextField();
|
matrixid_input_ = new TextField();
|
||||||
username_input_->setLabel("Username");
|
matrixid_input_->setLabel("Matrix ID");
|
||||||
username_input_->setInkColor("#577275");
|
matrixid_input_->setInkColor("#577275");
|
||||||
username_input_->setBackgroundColor("#f9f9f9");
|
matrixid_input_->setBackgroundColor("#f9f9f9");
|
||||||
|
matrixid_input_->setPlaceholderText("e.g @joe:matrix.org");
|
||||||
|
|
||||||
password_input_ = new TextField();
|
password_input_ = new TextField();
|
||||||
password_input_->setLabel("Password");
|
password_input_->setLabel("Password");
|
||||||
|
@ -73,7 +74,7 @@ LoginPage::LoginPage(QWidget *parent)
|
||||||
password_input_->setBackgroundColor("#f9f9f9");
|
password_input_->setBackgroundColor("#f9f9f9");
|
||||||
password_input_->setEchoMode(QLineEdit::Password);
|
password_input_->setEchoMode(QLineEdit::Password);
|
||||||
|
|
||||||
form_layout_->addWidget(username_input_, Qt::AlignHCenter, 0);
|
form_layout_->addWidget(matrixid_input_, Qt::AlignHCenter, 0);
|
||||||
form_layout_->addWidget(password_input_, Qt::AlignHCenter, 0);
|
form_layout_->addWidget(password_input_, Qt::AlignHCenter, 0);
|
||||||
|
|
||||||
button_layout_ = new QHBoxLayout();
|
button_layout_ = new QHBoxLayout();
|
||||||
|
@ -106,10 +107,10 @@ LoginPage::LoginPage(QWidget *parent)
|
||||||
|
|
||||||
connect(back_button_, SIGNAL(clicked()), this, SLOT(onBackButtonClicked()));
|
connect(back_button_, SIGNAL(clicked()), this, SLOT(onBackButtonClicked()));
|
||||||
connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked()));
|
connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked()));
|
||||||
connect(username_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
connect(matrixid_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||||
connect(password_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
connect(password_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||||
|
|
||||||
username_input_->setValidator(matrix_id_validator_->id_);
|
matrixid_input_->setValidator(matrix_id_validator_->id_);
|
||||||
|
|
||||||
setLayout(top_layout_);
|
setLayout(top_layout_);
|
||||||
}
|
}
|
||||||
|
@ -124,13 +125,13 @@ void LoginPage::onLoginButtonClicked()
|
||||||
{
|
{
|
||||||
error_label_->setText("");
|
error_label_->setText("");
|
||||||
|
|
||||||
if (!username_input_->hasAcceptableInput()) {
|
if (!matrixid_input_->hasAcceptableInput()) {
|
||||||
loginError("Invalid Matrix ID");
|
loginError("Invalid Matrix ID");
|
||||||
} else if (password_input_->text().isEmpty()) {
|
} else if (password_input_->text().isEmpty()) {
|
||||||
loginError("Empty password");
|
loginError("Empty password");
|
||||||
} else {
|
} else {
|
||||||
QString user = username_input_->text().split("@").at(0);
|
QString user = matrixid_input_->text().split(":").at(0).split("@").at(1);
|
||||||
QString home_server = username_input_->text().split("@").at(1);
|
QString home_server = matrixid_input_->text().split(":").at(1);
|
||||||
QString password = password_input_->text();
|
QString password = password_input_->text();
|
||||||
|
|
||||||
emit userLogin(user, password, home_server);
|
emit userLogin(user, password, home_server);
|
||||||
|
@ -139,7 +140,7 @@ void LoginPage::onLoginButtonClicked()
|
||||||
|
|
||||||
void LoginPage::reset()
|
void LoginPage::reset()
|
||||||
{
|
{
|
||||||
username_input_->clear();
|
matrixid_input_->clear();
|
||||||
password_input_->clear();
|
password_input_->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue