Prevent logging into the same account twice
Check if an account is already logged in before allow the login process to continue. BUG:459603
This commit is contained in:
@@ -3,6 +3,12 @@
|
|||||||
|
|
||||||
#include "login.h"
|
#include "login.h"
|
||||||
|
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
|
#include <accountregistry.h>
|
||||||
|
#else
|
||||||
|
#include "neochataccountregistry.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <connection.h>
|
#include <connection.h>
|
||||||
#include <qt_connection_util.h>
|
#include <qt_connection_util.h>
|
||||||
|
|
||||||
@@ -39,6 +45,12 @@ void Login::init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isLoggedIn = AccountRegistry::instance().isLoggedIn(m_matrixId);
|
||||||
|
Q_EMIT isLoggedInChanged();
|
||||||
|
if (m_isLoggedIn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_testing = true;
|
m_testing = true;
|
||||||
Q_EMIT testingChanged();
|
Q_EMIT testingChanged();
|
||||||
if (!m_connection) {
|
if (!m_connection) {
|
||||||
@@ -181,3 +193,8 @@ bool Login::isLoggingIn() const
|
|||||||
{
|
{
|
||||||
return m_isLoggingIn;
|
return m_isLoggingIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Login::isLoggedIn() const
|
||||||
|
{
|
||||||
|
return m_isLoggedIn;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class Login : public QObject
|
|||||||
Q_PROPERTY(bool supportsPassword READ supportsPassword NOTIFY loginFlowsChanged STORED false)
|
Q_PROPERTY(bool supportsPassword READ supportsPassword NOTIFY loginFlowsChanged STORED false)
|
||||||
Q_PROPERTY(QUrl ssoUrl READ ssoUrl NOTIFY ssoUrlChanged)
|
Q_PROPERTY(QUrl ssoUrl READ ssoUrl NOTIFY ssoUrlChanged)
|
||||||
Q_PROPERTY(bool isLoggingIn READ isLoggingIn NOTIFY isLoggingInChanged)
|
Q_PROPERTY(bool isLoggingIn READ isLoggingIn NOTIFY isLoggingInChanged)
|
||||||
|
Q_PROPERTY(bool isLoggedIn READ isLoggedIn NOTIFY isLoggedInChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Login(QObject *parent = nullptr);
|
explicit Login(QObject *parent = nullptr);
|
||||||
@@ -49,6 +50,8 @@ public:
|
|||||||
|
|
||||||
bool isLoggingIn() const;
|
bool isLoggingIn() const;
|
||||||
|
|
||||||
|
bool isLoggedIn() const;
|
||||||
|
|
||||||
Q_INVOKABLE void login();
|
Q_INVOKABLE void login();
|
||||||
Q_INVOKABLE void loginWithSso();
|
Q_INVOKABLE void loginWithSso();
|
||||||
|
|
||||||
@@ -64,6 +67,7 @@ Q_SIGNALS:
|
|||||||
void errorOccured(QString message);
|
void errorOccured(QString message);
|
||||||
void testingChanged();
|
void testingChanged();
|
||||||
void isLoggingInChanged();
|
void isLoggingInChanged();
|
||||||
|
void isLoggedInChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setHomeserverReachable(bool reachable);
|
void setHomeserverReachable(bool reachable);
|
||||||
@@ -78,4 +82,5 @@ private:
|
|||||||
QUrl m_ssoUrl;
|
QUrl m_ssoUrl;
|
||||||
bool m_testing = false;
|
bool m_testing = false;
|
||||||
bool m_isLoggingIn = false;
|
bool m_isLoggingIn = false;
|
||||||
|
bool m_isLoggedIn = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ LoginStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action: Kirigami.Action {
|
action: Kirigami.Action {
|
||||||
text: LoginHelper.testing && matrixIdField.acceptableInput ? i18n("Loading…") : i18nc("@action:button", "Continue")
|
text: LoginHelper.testing && matrixIdField.acceptableInput ? (LoginHelper.isLoggedIn ? i18n("Already logged in") : i18n("Loading…")) : i18nc("@action:button", "Continue")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (LoginHelper.supportsSso && LoginHelper.supportsPassword) {
|
if (LoginHelper.supportsSso && LoginHelper.supportsPassword) {
|
||||||
processed("qrc:/LoginMethod.qml");
|
processed("qrc:/LoginMethod.qml");
|
||||||
|
|||||||
Reference in New Issue
Block a user