From f03cd3f4c62356e53f03a733afbad84d36ed1ed5 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Thu, 5 Jan 2023 00:42:56 +0000 Subject: [PATCH] Fix SSO login button needs to click twice to open login URL Before this patch, the `ssoUrlChanged` signal might emitted before the URL actually get changed. This patch ensure the signal emitted at the correct place, and also disable the Login button before `LoginHelper` done its work. To test this change, you can simply enter `@a:mozilla.org` (or whatever the account name is) and attempt to login it by click "continue". Then click the "Login" button and see if the first click can let your browser open the SSO login URL. --- src/login.cpp | 2 +- src/qml/Component/Login/Sso.qml | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/login.cpp b/src/login.cpp index 37dca19c8..6fa147508 100644 --- a/src/login.cpp +++ b/src/login.cpp @@ -181,8 +181,8 @@ void Login::loginWithSso() connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [this]() { SsoSession *session = m_connection->prepareForSso(m_deviceName); m_ssoUrl = session->ssoUrl(); + Q_EMIT ssoUrlChanged(); }); - Q_EMIT ssoUrlChanged(); } bool Login::testing() const diff --git a/src/qml/Component/Login/Sso.qml b/src/qml/Component/Login/Sso.qml index 8eb9f8f26..fc7219ee6 100644 --- a/src/qml/Component/Login/Sso.qml +++ b/src/qml/Component/Login/Sso.qml @@ -20,6 +20,9 @@ LoginStep { target: LoginHelper function onSsoUrlChanged() { UrlHelper.openUrl(LoginHelper.ssoUrl) + root.showMessage(i18n("Complete the authentication steps in your browser")) + loginButton.enabled = true + loginButton.text = i18n("Login") } function onConnected() { processed("qrc:/Loading.qml") @@ -34,10 +37,12 @@ LoginStep { } } QQC2.Button { + id: loginButton text: i18n("Login") onClicked: { LoginHelper.loginWithSso() - root.showMessage(i18n("Complete the authentication steps in your browser")) + loginButton.enabled = false + loginButton.text = i18n("Loading…") } Component.onCompleted: forceActiveFocus() Keys.onReturnPressed: clicked()