Use QInputDialog to get registration token

This commit is contained in:
Callum Brown 2021-08-12 16:41:29 +01:00
parent b56a1be0bd
commit 7d484a8228
4 changed files with 5 additions and 112 deletions

View file

@ -3,6 +3,7 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include <QInputDialog>
#include <QLabel>
#include <QMetaType>
#include <QPainter>
@ -25,7 +26,6 @@
#include "dialogs/FallbackAuth.h"
#include "dialogs/ReCaptcha.h"
#include "dialogs/TokenRegistration.h"
Q_DECLARE_METATYPE(mtx::user_interactive::Unauthorized)
Q_DECLARE_METATYPE(mtx::user_interactive::Auth)
@ -483,22 +483,10 @@ RegisterPage::doUIA(const mtx::user_interactive::Unauthorized &unauthorized)
mtx::user_interactive::Auth{session, mtx::user_interactive::auth::Dummy{}});
} else if (current_stage == mtx::user_interactive::auth_types::registration_token) {
auto dialog = new dialogs::TokenRegistration(this);
connect(dialog,
&dialogs::TokenRegistration::confirmation,
this,
[this, session, dialog](std::string token) {
dialog->close();
dialog->deleteLater();
emit registrationWithAuth(mtx::user_interactive::Auth{
session, mtx::user_interactive::auth::RegistrationToken{token}});
});
connect(
dialog, &dialogs::TokenRegistration::cancel, this, &RegisterPage::errorOccurred);
dialog->show();
QString token = QInputDialog::getText(
this, tr("Registration token"), tr("Please enter a valid registration token."));
emit registrationWithAuth(mtx::user_interactive::Auth{
session, mtx::user_interactive::auth::RegistrationToken{token.toStdString()}});
} else {
// use fallback
auto dialog = new dialogs::FallbackAuth(