mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Flow2: Poll for auth result upon account setup wizard 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 wizard 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 wizard's window activation event down to the Login Flow v2 page, in order to allow it to poll earlier. Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
parent
3a160a4dce
commit
e8348612b4
6 changed files with 26 additions and 1 deletions
|
@ -177,4 +177,11 @@ void Flow2Auth::slotPollTimerTimeout()
|
|||
});
|
||||
}
|
||||
|
||||
void Flow2Auth::slotPollNow()
|
||||
{
|
||||
// poll now if we're not already doing so
|
||||
if(_pollTimer.isActive())
|
||||
slotPollTimerTimeout();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace OCC {
|
|||
* Job that does the authorization, grants and fetches the access token via Login Flow v2
|
||||
*
|
||||
* See: https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html#login-flow-v2
|
||||
*
|
||||
*/
|
||||
class Flow2Auth : public QObject
|
||||
{
|
||||
|
@ -53,6 +52,9 @@ signals:
|
|||
*/
|
||||
void result(Flow2Auth::Result result, const QString &user = QString(), const QString &appPassword = QString());
|
||||
|
||||
public slots:
|
||||
void slotPollNow();
|
||||
|
||||
private slots:
|
||||
void slotPollTimerTimeout();
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ void Flow2AuthCredsPage::initializePage()
|
|||
ocWizard->account()->setCredentials(CredentialsFactory::create("http"));
|
||||
_asyncAuth.reset(new Flow2Auth(ocWizard->account().data(), this));
|
||||
connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthCredsPage::asyncAuthResult, Qt::QueuedConnection);
|
||||
connect(this, &Flow2AuthCredsPage::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow);
|
||||
_asyncAuth->start();
|
||||
|
||||
// Don't hide the wizard (avoid user confusion)!
|
||||
|
@ -153,4 +154,9 @@ void Flow2AuthCredsPage::slotCopyLinkToClipboard()
|
|||
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
||||
}
|
||||
|
||||
void Flow2AuthCredsPage::slotPollNow()
|
||||
{
|
||||
emit pollNow();
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -47,9 +47,11 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void asyncAuthResult(Flow2Auth::Result, const QString &user, const QString &appPassword);
|
||||
void slotPollNow();
|
||||
|
||||
signals:
|
||||
void connectToOCUrl(const QString &);
|
||||
void pollNow();
|
||||
|
||||
public:
|
||||
QString _user;
|
||||
|
|
|
@ -107,6 +107,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
|
|||
connect(this, &OwncloudWizard::styleChanged, _advancedSetupPage, &OwncloudAdvancedSetupPage::slotStyleChanged);
|
||||
|
||||
customizeStyle();
|
||||
|
||||
// allow Flow2 page to poll on window activation
|
||||
connect(this, &OwncloudWizard::onActivate, _flow2CredsPage, &Flow2AuthCredsPage::slotPollNow);
|
||||
}
|
||||
|
||||
void OwncloudWizard::setAccount(AccountPtr account)
|
||||
|
@ -295,6 +298,10 @@ void OwncloudWizard::changeEvent(QEvent *e)
|
|||
// Notify the other widgets (Dark-/Light-Mode switching)
|
||||
emit styleChanged();
|
||||
break;
|
||||
case QEvent::ActivationChange:
|
||||
if(isActiveWindow())
|
||||
emit onActivate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ signals:
|
|||
void skipFolderConfiguration();
|
||||
void needCertificate();
|
||||
void styleChanged();
|
||||
void onActivate();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *) override;
|
||||
|
|
Loading…
Reference in a new issue