mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Flow2: Poll for re-auth result upon WebFlowCredentialsDialog window activation
Since the default remote poll interval has been re-raised recently to 30 seconds, the delay between clicking "Grant access" in the browser and fetch and showing success in the dialog may seem erroneous to the users and tempt them to click "Re-open browser" again, causing the whole login process to restart. This commit implements an event handler to pass the dialog's window activation event down to the Login Flow v2 widget, in order to allow it to poll earlier. See previous commits for dependent implementation details. Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
parent
aa18667905
commit
e04aae94bc
4 changed files with 27 additions and 0 deletions
|
@ -32,6 +32,9 @@ WebFlowCredentialsDialog::WebFlowCredentialsDialog(Account *account, bool useFlo
|
|||
_layout->addWidget(_flow2AuthWidget);
|
||||
|
||||
connect(_flow2AuthWidget, &Flow2AuthWidget::urlCatched, this, &WebFlowCredentialsDialog::urlCatched);
|
||||
|
||||
// allow Flow2 page to poll on window activation
|
||||
connect(this, &WebFlowCredentialsDialog::onActivate, _flow2AuthWidget, &Flow2AuthWidget::slotPollNow);
|
||||
} else {
|
||||
_webView = new WebView();
|
||||
_layout->addWidget(_webView);
|
||||
|
@ -87,6 +90,20 @@ void WebFlowCredentialsDialog::setError(const QString &error) {
|
|||
}
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::ActivationChange:
|
||||
if(isActiveWindow())
|
||||
emit onActivate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QDialog::changeEvent(e);
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::slotShowSettingsDialog()
|
||||
{
|
||||
// bring window to top but slightly delay, to avoid being hidden behind the SettingsDialog
|
||||
|
|
|
@ -30,12 +30,14 @@ public:
|
|||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent * e) override;
|
||||
void changeEvent(QEvent *) override;
|
||||
|
||||
public slots:
|
||||
void slotShowSettingsDialog();
|
||||
|
||||
signals:
|
||||
void urlCatched(const QString user, const QString pass, const QString host);
|
||||
void onActivate();
|
||||
|
||||
private:
|
||||
bool _useFlow2;
|
||||
|
|
|
@ -55,6 +55,7 @@ Flow2AuthWidget::Flow2AuthWidget(Account *account, QWidget *parent)
|
|||
|
||||
_asyncAuth.reset(new Flow2Auth(_account, this));
|
||||
connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::asyncAuthResult, Qt::QueuedConnection);
|
||||
connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow);
|
||||
_asyncAuth->start();
|
||||
}
|
||||
|
||||
|
@ -112,4 +113,9 @@ void Flow2AuthWidget::slotCopyLinkToClipboard()
|
|||
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
||||
}
|
||||
|
||||
void Flow2AuthWidget::slotPollNow()
|
||||
{
|
||||
emit pollNow();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -35,9 +35,11 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void asyncAuthResult(Flow2Auth::Result, const QString &user, const QString &appPassword);
|
||||
void slotPollNow();
|
||||
|
||||
signals:
|
||||
void urlCatched(const QString user, const QString pass, const QString host);
|
||||
void pollNow();
|
||||
|
||||
private:
|
||||
Account *_account;
|
||||
|
|
Loading…
Reference in a new issue