summary refs log tree commit diff
path: root/src/RegisterPage.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-12 22:23:26 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-12 22:23:26 +0200
commit4659d0efc274f2a955b203ca5b00cf1dfc26d5fc (patch)
treede791031bf883a20932c878cd7a9a5d240dc3a49 /src/RegisterPage.cc
parentUpdate room name & avatar on new rooms (diff)
downloadnheko-4659d0efc274f2a955b203ca5b00cf1dfc26d5fc.tar.xz
Implement user registration with reCAPTCHA
fixes #264
Diffstat (limited to 'src/RegisterPage.cc')
-rw-r--r--src/RegisterPage.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/RegisterPage.cc b/src/RegisterPage.cc

index 044d2fcf..c0fa11a6 100644 --- a/src/RegisterPage.cc +++ b/src/RegisterPage.cc
@@ -16,14 +16,18 @@ */ #include <QStyleOption> +#include <QTimer> #include "Config.h" #include "FlatButton.h" +#include "MainWindow.h" #include "MatrixClient.h" #include "RaisedButton.h" #include "RegisterPage.h" #include "TextField.h" +#include "dialogs/ReCaptcha.hpp" + RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent) : QWidget(parent) , client_(client) @@ -126,6 +130,30 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent) SIGNAL(registerError(const QString &)), this, SLOT(registerError(const QString &))); + connect(client_.data(), + &MatrixClient::registrationFlow, + this, + [this](const QString &user, + const QString &pass, + const QString &server, + const QString &session) { + emit errorOccurred(); + + if (!captchaDialog_) { + captchaDialog_ = + std::make_shared<dialogs::ReCaptcha>(server, session, this); + connect(captchaDialog_.get(), + &dialogs::ReCaptcha::closing, + this, + [this, user, pass, server, session]() { + captchaDialog_->close(); + emit registering(); + client_->registerUser(user, pass, server, session); + }); + } + + QTimer::singleShot(1000, this, [this]() { captchaDialog_->show(); }); + }); setLayout(top_layout_); } @@ -139,6 +167,7 @@ RegisterPage::onBackButtonClicked() void RegisterPage::registerError(const QString &msg) { + emit errorOccurred(); error_label_->setText(msg); } @@ -161,6 +190,7 @@ RegisterPage::onRegisterButtonClicked() QString server = server_input_->text(); client_->registerUser(username, password, server); + emit registering(); } }