summary refs log tree commit diff
path: root/src/LoginPage.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-02-19 15:48:43 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-02-19 15:48:43 +0100
commitebd12a6f33fa2cff04da1756b1363a3f4ec45f90 (patch)
treec79af7f6bf8055c5cfaa0f1644b626b3358d646a /src/LoginPage.cpp
parentMerge pull request #479 from Jedi18/add_rooms_model_completer (diff)
downloadnheko-ebd12a6f33fa2cff04da1756b1363a3f4ec45f90.tar.xz
Fix login with SSO and Password supported
Diffstat (limited to 'src/LoginPage.cpp')
-rw-r--r--src/LoginPage.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp

index 15aeb12a..26a170c5 100644 --- a/src/LoginPage.cpp +++ b/src/LoginPage.cpp
@@ -147,16 +147,23 @@ LoginPage::LoginPage(QWidget *parent) error_matrixid_label_->hide(); button_layout_ = new QHBoxLayout(); - button_layout_->setSpacing(0); + button_layout_->setSpacing(20); button_layout_->setContentsMargins(0, 0, 0, 30); login_button_ = new RaisedButton(tr("LOGIN"), this); - login_button_->setMinimumSize(350, 65); + login_button_->setMinimumSize(150, 65); login_button_->setFontSize(20); login_button_->setCornerRadius(3); + sso_login_button_ = new RaisedButton(tr("SSO LOGIN"), this); + sso_login_button_->setMinimumSize(150, 65); + sso_login_button_->setFontSize(20); + sso_login_button_->setCornerRadius(3); + sso_login_button_->setVisible(false); + button_layout_->addStretch(1); button_layout_->addWidget(login_button_); + button_layout_->addWidget(sso_login_button_); button_layout_->addStretch(1); error_label_ = new QLabel(this); @@ -179,7 +186,12 @@ LoginPage::LoginPage(QWidget *parent) this, &LoginPage::versionErrorCb, this, &LoginPage::versionError, Qt::QueuedConnection); connect(back_button_, SIGNAL(clicked()), this, SLOT(onBackButtonClicked())); - connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked())); + connect(login_button_, &RaisedButton::clicked, this, [this]() { + onLoginButtonClicked(passwordSupported ? LoginMethod::Password : LoginMethod::SSO); + }); + connect(sso_login_button_, &RaisedButton::clicked, this, [this]() { + onLoginButtonClicked(LoginMethod::SSO); + }); connect(matrixid_input_, SIGNAL(returnPressed()), login_button_, SLOT(click())); connect(password_input_, SIGNAL(returnPressed()), login_button_, SLOT(click())); connect(deviceName_, SIGNAL(returnPressed()), login_button_, SLOT(click())); @@ -314,16 +326,19 @@ LoginPage::checkHomeserverVersion() http::client()->get_login( [this](mtx::responses::LoginFlows flows, mtx::http::RequestErr err) { if (err || flows.flows.empty()) - emit versionOkCb(LoginMethod::Password); + emit versionOkCb(true, false); - LoginMethod loginMethod_ = LoginMethod::Password; + bool ssoSupported_ = false; + bool passwordSupported_ = false; for (const auto &flow : flows.flows) { if (flow.type == mtx::user_interactive::auth_types::sso) { - loginMethod_ = LoginMethod::SSO; - break; + ssoSupported_ = true; + } else if (flow.type == + mtx::user_interactive::auth_types::password) { + passwordSupported_ = true; } } - emit versionOkCb(loginMethod_); + emit versionOkCb(passwordSupported_, ssoSupported_); }); }); } @@ -355,28 +370,24 @@ LoginPage::versionError(const QString &error) } void -LoginPage::versionOk(LoginMethod loginMethod_) +LoginPage::versionOk(bool passwordSupported_, bool ssoSupported_) { - this->loginMethod = loginMethod_; + passwordSupported = passwordSupported_; + ssoSupported = ssoSupported_; serverLayout_->removeWidget(spinner_); matrixidLayout_->removeWidget(spinner_); spinner_->stop(); - if (loginMethod == LoginMethod::SSO) { - password_input_->hide(); - login_button_->setText(tr("SSO LOGIN")); - } else { - password_input_->show(); - login_button_->setText(tr("LOGIN")); - } + sso_login_button_->setVisible(ssoSupported); + login_button_->setVisible(passwordSupported); if (serverInput_->isVisible()) serverInput_->hide(); } void -LoginPage::onLoginButtonClicked() +LoginPage::onLoginButtonClicked(LoginMethod loginMethod) { error_label_->setText("");