From d257f0b6155d6d1450cf0c82d1538e553380c44e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 12 Jun 2020 20:36:29 +0200 Subject: Connection::isLoggedIn() and more robust logout() isLoggedIn() is just a wrapper around Connection::accessToken() that returns whether it's not empty. Now, Connection::accessToken() and Connection::logout() are changed in such a way that if there's a logout job ongoing Connection::accessToken() will return an empty value even though the access token is still stored in ConnectionData. This gives a hint to the rest of Connection and to the client code that the user is not quite authenticated anymore. Finally, syncLoop() and sync() have been altered to check isLoggedIn() before proceeding with their network request. --- lib/connection.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/connection.h b/lib/connection.h index fb76cf3d..e8373a10 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -139,6 +139,7 @@ class Connection : public QObject { Q_PROPERTY(QString domain READ domain NOTIFY stateChanged STORED false) Q_PROPERTY(QString deviceId READ deviceId NOTIFY stateChanged) Q_PROPERTY(QByteArray accessToken READ accessToken NOTIFY stateChanged) + Q_PROPERTY(bool isLoggedIn READ isLoggedIn NOTIFY stateChanged STORED false) Q_PROPERTY(QString defaultRoomVersion READ defaultRoomVersion NOTIFY capabilitiesLoaded) Q_PROPERTY(QUrl homeserver READ homeserver WRITE setHomeserver NOTIFY homeserverChanged) Q_PROPERTY(QVector loginFlows READ loginFlows NOTIFY loginFlowsChanged) @@ -338,6 +339,7 @@ public: QString userId() const; QString deviceId() const; QByteArray accessToken() const; + bool isLoggedIn() const; #ifdef Quotient_E2EE_ENABLED QtOlm::Account* olmAccount() const; #endif // Quotient_E2EE_ENABLED -- cgit v1.2.3