1111#include " account.h"
1212#include " configfile.h"
1313#include " theme.h"
14- #include " webflowcredentialsdialog .h"
14+ #include " wizard/browserreauthwindow .h"
1515#include " networkjobs.h"
1616
1717#include < QAuthenticator>
1818#include < QNetworkAccessManager>
1919#include < QNetworkReply>
2020#include < QPointer>
2121#include < QTimer>
22- #include < QDialog>
23- #include < QVBoxLayout>
24- #include < QLabel>
2522
2623using namespace QKeychain ;
2724
@@ -145,22 +142,31 @@ void WebFlowCredentials::fetchFromKeychain(const QString &appName) {
145142}
146143
147144void WebFlowCredentials::askFromUser () {
148- _askDialog = new WebFlowCredentialsDialog (_account);
145+ if (_reAuthWindow) {
146+ _reAuthWindow->show ();
147+ return ;
148+ }
149+
150+ _reAuthWindow = new BrowserReAuthWindow (_account, this );
149151
150152 QString msg = tr (" You have been logged out of your account %1 at %2. Please login again." )
151153 .arg (_account->prettyName (), _account->url ().toDisplayString ());
152- _askDialog-> setInfo (msg);
154+ _reAuthWindow-> setInfoText (msg);
153155
154- _askDialog->show ();
156+ connect (_reAuthWindow, &BrowserReAuthWindow::credentialsReady, this , &WebFlowCredentials::slotAskFromUserCredentialsProvided);
157+ connect (_reAuthWindow, &BrowserReAuthWindow::cancelled, this , &WebFlowCredentials::slotAskFromUserCancelled);
155158
156- connect (_askDialog, &WebFlowCredentialsDialog::urlCatched, this , &WebFlowCredentials::slotAskFromUserCredentialsProvided);
157- connect (_askDialog, &WebFlowCredentialsDialog::onClose, this , &WebFlowCredentials::slotAskFromUserCancelled);
159+ _reAuthWindow->show ();
158160
159161 qCDebug (lcWebFlowCredentials ()) << " User needs to reauth!" ;
160162}
161163
162- void WebFlowCredentials::slotAskFromUserCredentialsProvided (const QString &user, const QString &pass, const QString &host) {
163- Q_UNUSED (host)
164+ void WebFlowCredentials::slotAskFromUserCredentialsProvided (const QString &user, const QString &pass) {
165+ auto *const reAuthWindow = qobject_cast<BrowserReAuthWindow *>(sender ());
166+ if (!reAuthWindow || reAuthWindow != _reAuthWindow) {
167+ return ;
168+ }
169+ _reAuthWindow = nullptr ;
164170
165171 qCInfo (lcWebFlowCredentials ()) << " Obtained a new password" ;
166172
@@ -170,18 +176,18 @@ void WebFlowCredentials::slotAskFromUserCredentialsProvided(const QString &user,
170176 _credentialsValid = true ;
171177 persist ();
172178 emit asked ();
173-
174- _askDialog->close ();
175- _askDialog = nullptr ;
176179}
177180
178181void WebFlowCredentials::slotAskFromUserCancelled () {
182+ auto *const reAuthWindow = qobject_cast<BrowserReAuthWindow *>(sender ());
183+ if (!reAuthWindow || reAuthWindow != _reAuthWindow) {
184+ return ;
185+ }
186+ _reAuthWindow = nullptr ;
187+
179188 qCDebug (lcWebFlowCredentials ()) << " User cancelled reauth!" ;
180189
181190 emit asked ();
182-
183- _askDialog->deleteLater ();
184- _askDialog = nullptr ;
185191}
186192
187193bool WebFlowCredentials::stillValid (QNetworkReply *reply) {
0 commit comments