|
|
@ -18,7 +18,6 @@ |
|
|
|
#include "Logging.h" |
|
|
|
#include "Logging.h" |
|
|
|
#include "LoginPage.h" |
|
|
|
#include "LoginPage.h" |
|
|
|
#include "MatrixClient.h" |
|
|
|
#include "MatrixClient.h" |
|
|
|
#include "SSOHandler.h" |
|
|
|
|
|
|
|
#include "UserSettingsPage.h" |
|
|
|
#include "UserSettingsPage.h" |
|
|
|
#include "ui/FlatButton.h" |
|
|
|
#include "ui/FlatButton.h" |
|
|
|
#include "ui/LoadingIndicator.h" |
|
|
|
#include "ui/LoadingIndicator.h" |
|
|
@ -26,6 +25,10 @@ |
|
|
|
#include "ui/RaisedButton.h" |
|
|
|
#include "ui/RaisedButton.h" |
|
|
|
#include "ui/TextField.h" |
|
|
|
#include "ui/TextField.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_ANDROID |
|
|
|
|
|
|
|
#include "SSOHandler.h" |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(LoginPage::LoginMethod) |
|
|
|
Q_DECLARE_METATYPE(LoginPage::LoginMethod) |
|
|
|
|
|
|
|
|
|
|
|
using namespace mtx::identifiers; |
|
|
|
using namespace mtx::identifiers; |
|
|
@ -144,15 +147,19 @@ LoginPage::LoginPage(QWidget *parent) |
|
|
|
login_button_->setFontSize(20); |
|
|
|
login_button_->setFontSize(20); |
|
|
|
login_button_->setCornerRadius(3); |
|
|
|
login_button_->setCornerRadius(3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_ANDROID |
|
|
|
sso_login_button_ = new RaisedButton(tr("SSO LOGIN"), this); |
|
|
|
sso_login_button_ = new RaisedButton(tr("SSO LOGIN"), this); |
|
|
|
sso_login_button_->setMinimumSize(150, 65); |
|
|
|
sso_login_button_->setMinimumSize(150, 65); |
|
|
|
sso_login_button_->setFontSize(20); |
|
|
|
sso_login_button_->setFontSize(20); |
|
|
|
sso_login_button_->setCornerRadius(3); |
|
|
|
sso_login_button_->setCornerRadius(3); |
|
|
|
sso_login_button_->setVisible(false); |
|
|
|
sso_login_button_->setVisible(false); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
button_layout_->addStretch(1); |
|
|
|
button_layout_->addStretch(1); |
|
|
|
button_layout_->addWidget(login_button_); |
|
|
|
button_layout_->addWidget(login_button_); |
|
|
|
|
|
|
|
#ifndef Q_OS_ANDROID |
|
|
|
button_layout_->addWidget(sso_login_button_); |
|
|
|
button_layout_->addWidget(sso_login_button_); |
|
|
|
|
|
|
|
#endif |
|
|
|
button_layout_->addStretch(1); |
|
|
|
button_layout_->addStretch(1); |
|
|
|
|
|
|
|
|
|
|
|
error_label_ = new QLabel(this); |
|
|
|
error_label_ = new QLabel(this); |
|
|
@ -178,9 +185,12 @@ LoginPage::LoginPage(QWidget *parent) |
|
|
|
connect(login_button_, &RaisedButton::clicked, this, [this]() { |
|
|
|
connect(login_button_, &RaisedButton::clicked, this, [this]() { |
|
|
|
onLoginButtonClicked(passwordSupported ? LoginMethod::Password : LoginMethod::SSO); |
|
|
|
onLoginButtonClicked(passwordSupported ? LoginMethod::Password : LoginMethod::SSO); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_ANDROID |
|
|
|
connect(sso_login_button_, &RaisedButton::clicked, this, [this]() { |
|
|
|
connect(sso_login_button_, &RaisedButton::clicked, this, [this]() { |
|
|
|
onLoginButtonClicked(LoginMethod::SSO); |
|
|
|
onLoginButtonClicked(LoginMethod::SSO); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
#endif |
|
|
|
connect(this, |
|
|
|
connect(this, |
|
|
|
&LoginPage::showErrorMessage, |
|
|
|
&LoginPage::showErrorMessage, |
|
|
|
this, |
|
|
|
this, |
|
|
@ -375,7 +385,9 @@ LoginPage::versionOk(bool passwordSupported_, bool ssoSupported_) |
|
|
|
matrixidLayout_->removeWidget(spinner_); |
|
|
|
matrixidLayout_->removeWidget(spinner_); |
|
|
|
spinner_->stop(); |
|
|
|
spinner_->stop(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_ANDROID |
|
|
|
sso_login_button_->setVisible(ssoSupported); |
|
|
|
sso_login_button_->setVisible(ssoSupported); |
|
|
|
|
|
|
|
#endif |
|
|
|
login_button_->setVisible(passwordSupported); |
|
|
|
login_button_->setVisible(passwordSupported); |
|
|
|
|
|
|
|
|
|
|
|
if (serverInput_->isVisible()) |
|
|
|
if (serverInput_->isVisible()) |
|
|
@ -435,6 +447,7 @@ LoginPage::onLoginButtonClicked(LoginMethod loginMethod) |
|
|
|
emit loginOk(res); |
|
|
|
emit loginOk(res); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
#ifndef Q_OS_ANDROID |
|
|
|
auto sso = new SSOHandler(); |
|
|
|
auto sso = new SSOHandler(); |
|
|
|
connect(sso, &SSOHandler::ssoSuccess, this, [this, sso](std::string token) { |
|
|
|
connect(sso, &SSOHandler::ssoSuccess, this, [this, sso](std::string token) { |
|
|
|
mtx::requests::Login req{}; |
|
|
|
mtx::requests::Login req{}; |
|
|
@ -472,6 +485,7 @@ LoginPage::onLoginButtonClicked(LoginMethod loginMethod) |
|
|
|
|
|
|
|
|
|
|
|
QDesktopServices::openUrl( |
|
|
|
QDesktopServices::openUrl( |
|
|
|
QString::fromStdString(http::client()->login_sso_redirect(sso->url()))); |
|
|
|
QString::fromStdString(http::client()->login_sso_redirect(sso->url()))); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
emit loggingIn(); |
|
|
|
emit loggingIn(); |
|
|
|