summary refs log tree commit diff
path: root/src/RegisterPage.cpp
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-05 18:05:27 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-05 18:05:27 +0300
commit0c6a3b6282293b5539d8711663df8d71d45f6892 (patch)
tree5bf379f74ed2c2b0aec91d9565bb029161af41ee /src/RegisterPage.cpp
parentFallback to the login screen when the one-time keys cannot be uploaded (diff)
downloadnheko-0c6a3b6282293b5539d8711663df8d71d45f6892.tar.xz
Remove captcha dialog from the member list
Diffstat (limited to 'src/RegisterPage.cpp')
-rw-r--r--src/RegisterPage.cpp74
1 files changed, 37 insertions, 37 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<dialogs::ReCaptcha>(
-                            QString::fromStdString(session), this);
-                          connect(
-                            captchaDialog_.get(),
-                            &dialogs::ReCaptcha::closing,
-                            this,
-                            [this, user, pass, session]() {
-                                    captchaDialog_->close();
-                                    emit registering();
-
-                                    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;
-                                              }
-
-                                              http::client()->set_user(res.user_id);
-                                              http::client()->set_access_token(res.access_token);
-
-                                              emit registerOk();
-                                      });
-                            });
-                  }
-
-                  QTimer::singleShot(1000, this, [this]() { captchaDialog_->show(); });
+                  auto captchaDialog =
+                    new dialogs::ReCaptcha(QString::fromStdString(session), this);
+
+                  connect(captchaDialog,
+                          &dialogs::ReCaptcha::closing,
+                          this,
+                          [this, user, pass, session, captchaDialog]() {
+                                  captchaDialog->close();
+                                  captchaDialog->deleteLater();
+
+                                  emit registering();
+
+                                  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;
+                                            }
+
+                                            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_);