From 0c6a3b6282293b5539d8711663df8d71d45f6892 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Wed, 5 Sep 2018 18:05:27 +0300 Subject: [PATCH] Remove captcha dialog from the member list --- src/RegisterPage.cpp | 66 ++++++++++++++++++++++---------------------- src/RegisterPage.h | 7 ----- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/src/RegisterPage.cpp b/src/RegisterPage.cpp index 5a02713a..dcf60dee 100644 --- a/src/RegisterPage.cpp +++ b/src/RegisterPage.cpp @@ -134,43 +134,43 @@ RegisterPage::RegisterPage(QWidget *parent) [this](const std::string &user, const std::string &pass, const std::string &session) { emit errorOccurred(); - if (!captchaDialog_) { - captchaDialog_ = std::make_shared( - QString::fromStdString(session), this); - connect( - captchaDialog_.get(), - &dialogs::ReCaptcha::closing, - this, - [this, user, pass, session]() { - captchaDialog_->close(); - emit registering(); + auto captchaDialog = + new dialogs::ReCaptcha(QString::fromStdString(session), this); - http::client()->flow_response( - user, - pass, - session, - "m.login.recaptcha", - [this](const mtx::responses::Register &res, - mtx::http::RequestErr err) { - if (err) { - nhlog::net()->warn( - "failed to retrieve registration flows: {}", - err->matrix_error.error); - emit errorOccurred(); - emit registerErrorCb(QString::fromStdString( - err->matrix_error.error)); - return; - } + connect(captchaDialog, + &dialogs::ReCaptcha::closing, + this, + [this, user, pass, session, captchaDialog]() { + captchaDialog->close(); + captchaDialog->deleteLater(); - http::client()->set_user(res.user_id); - http::client()->set_access_token(res.access_token); + emit registering(); - emit registerOk(); - }); - }); - } + http::client()->flow_response( + user, + pass, + session, + "m.login.recaptcha", + [this](const mtx::responses::Register &res, + mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn( + "failed to retrieve registration flows: {}", + err->matrix_error.error); + emit errorOccurred(); + emit registerErrorCb(QString::fromStdString( + err->matrix_error.error)); + return; + } - QTimer::singleShot(1000, this, [this]() { captchaDialog_->show(); }); + http::client()->set_user(res.user_id); + http::client()->set_access_token(res.access_token); + + emit registerOk(); + }); + }); + + QTimer::singleShot(1000, this, [captchaDialog]() { captchaDialog->show(); }); }); setLayout(top_layout_); diff --git a/src/RegisterPage.h b/src/RegisterPage.h index 1f39ab0c..b05cf150 100644 --- a/src/RegisterPage.h +++ b/src/RegisterPage.h @@ -25,10 +25,6 @@ class FlatButton; class RaisedButton; class TextField; -namespace dialogs { -class ReCaptcha; -} - class RegisterPage : public QWidget { Q_OBJECT @@ -77,7 +73,4 @@ private: TextField *password_input_; TextField *password_confirmation_; TextField *server_input_; - - //! ReCaptcha dialog. - std::shared_ptr captchaDialog_; };