mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:19:06 +02:00
Titlebar now responds correctly to domain logged in state.
This commit is contained in:
parent
448cdcb31f
commit
6b0fc8fd66
3 changed files with 22 additions and 18 deletions
|
@ -7085,7 +7085,7 @@ void Application::updateWindowTitle() const {
|
||||||
auto isInErrorState = nodeList->getDomainHandler().isInErrorState();
|
auto isInErrorState = nodeList->getDomainHandler().isInErrorState();
|
||||||
bool isMetaverseLoggedIn = accountManager->isLoggedIn();
|
bool isMetaverseLoggedIn = accountManager->isLoggedIn();
|
||||||
bool isDomainLoggedIn = domainAccountManager->isLoggedIn();
|
bool isDomainLoggedIn = domainAccountManager->isLoggedIn();
|
||||||
qCDebug(interfaceapp) << "Is Logged Into Domain:" << isDomainLoggedIn;
|
QString authedDomain = domainAccountManager->getAuthedDomain();
|
||||||
|
|
||||||
QString buildVersion = " - Vircadia - "
|
QString buildVersion = " - Vircadia - "
|
||||||
+ (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build"))
|
+ (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build"))
|
||||||
|
@ -7095,8 +7095,7 @@ void Application::updateWindowTitle() const {
|
||||||
nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)";
|
nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)";
|
||||||
|
|
||||||
QString metaverseUsername = accountManager->getAccountInfo().getUsername();
|
QString metaverseUsername = accountManager->getAccountInfo().getUsername();
|
||||||
// ###### TODO
|
QString domainUsername = domainAccountManager->getUsername();
|
||||||
// QString domainUsername = domainAccountManager->getUsername();
|
|
||||||
|
|
||||||
setCrashAnnotation("sentry[user][metaverseUsername]", metaverseUsername.toStdString());
|
setCrashAnnotation("sentry[user][metaverseUsername]", metaverseUsername.toStdString());
|
||||||
|
|
||||||
|
@ -7122,10 +7121,10 @@ void Application::updateWindowTitle() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString domainDetails;
|
QString domainDetails;
|
||||||
if (isDomainLoggedIn) {
|
if (currentPlaceName == authedDomain && isDomainLoggedIn) {
|
||||||
// ###### TODO
|
// ###### TODO
|
||||||
// domainDetails = "Domain: Logged in as " + domainUsername;
|
// domainDetails = "Domain: Logged in as " + domainUsername;
|
||||||
domainDetails = "Domain: Logged In";
|
domainDetails = "Domain: Logged in as " + domainUsername;
|
||||||
} else {
|
} else {
|
||||||
domainDetails = "Domain: Not Logged In";
|
domainDetails = "Domain: Not Logged In";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
|
#include "NodeList.h"
|
||||||
#include "NetworkingConstants.h"
|
#include "NetworkingConstants.h"
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
#include "NetworkAccessManager.h"
|
#include "NetworkAccessManager.h"
|
||||||
|
@ -101,6 +103,8 @@ void DomainAccountManager::requestAccessTokenFinished() {
|
||||||
// miniOrange plugin provides no scope.
|
// miniOrange plugin provides no scope.
|
||||||
if (rootObject.contains("access_token")) {
|
if (rootObject.contains("access_token")) {
|
||||||
// Success.
|
// Success.
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
_domain_name = nodeList->getDomainHandler().getHostname();
|
||||||
QUrl rootURL = requestReply->url();
|
QUrl rootURL = requestReply->url();
|
||||||
rootURL.setPath("");
|
rootURL.setPath("");
|
||||||
setTokensFromJSON(rootObject, rootURL);
|
setTokensFromJSON(rootObject, rootURL);
|
||||||
|
@ -133,10 +137,12 @@ bool DomainAccountManager::accessTokenIsExpired() {
|
||||||
|
|
||||||
|
|
||||||
bool DomainAccountManager::hasValidAccessToken() {
|
bool DomainAccountManager::hasValidAccessToken() {
|
||||||
QString currentDomainAccessToken = domainAccessToken.get();
|
// ###### TODO: wire this up to actually retrieve a token (based on session or storage) and confirm that it is in fact valid and relevant to the current domain.
|
||||||
|
// QString currentDomainAccessToken = domainAccessToken.get();
|
||||||
if (currentDomainAccessToken.isEmpty() || accessTokenIsExpired()) {
|
QString currentDomainAccessToken = _access_token;
|
||||||
|
|
||||||
|
// if (currentDomainAccessToken.isEmpty() || accessTokenIsExpired()) {
|
||||||
|
if (currentDomainAccessToken.isEmpty()) {
|
||||||
if (VERBOSE_HTTP_REQUEST_DEBUGGING) {
|
if (VERBOSE_HTTP_REQUEST_DEBUGGING) {
|
||||||
qCDebug(networking) << "An access token is required for requests to"
|
qCDebug(networking) << "An access token is required for requests to"
|
||||||
<< qPrintable(_authURL.toString());
|
<< qPrintable(_authURL.toString());
|
||||||
|
@ -153,23 +159,20 @@ bool DomainAccountManager::hasValidAccessToken() {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainAccountManager::setTokensFromJSON(const QJsonObject& jsonObject, const QUrl& url) {
|
void DomainAccountManager::setTokensFromJSON(const QJsonObject& jsonObject, const QUrl& url) {
|
||||||
_access_token = jsonObject["access_token"].toString();
|
_access_token = jsonObject["access_token"].toString();
|
||||||
_refresh_token = jsonObject["refresh_token"].toString();
|
_refresh_token = jsonObject["refresh_token"].toString();
|
||||||
|
|
||||||
// ####### TODO: Enable and use these.
|
|
||||||
// ####### TODO: Protect these per AccountManager?
|
// ####### TODO: Protect these per AccountManager?
|
||||||
// ######: TODO: clientID needed?
|
// ######: TODO: clientID needed?
|
||||||
/*
|
|
||||||
qCDebug(networking) << "Storing a domain account with access-token for" << qPrintable(url.toString());
|
// qCDebug(networking) << "Storing a domain account with access-token for" << qPrintable(url.toString());
|
||||||
domainAccessToken.set(jsonObject["access_token"].toString());
|
// domainAccessToken.set(jsonObject["access_token"].toString());
|
||||||
domainAccessRefreshToken.set(jsonObject["refresh_token"].toString());
|
// domainAccessRefreshToken.set(jsonObject["refresh_token"].toString());
|
||||||
domainAccessTokenExpiresIn.set(QDateTime::currentMSecsSinceEpoch() + (jsonObject["expires_in"].toDouble() * 1000));
|
// domainAccessTokenExpiresIn.set(QDateTime::currentMSecsSinceEpoch() + (jsonObject["expires_in"].toDouble() * 1000));
|
||||||
domainAccessTokenType.set(jsonObject["token_type"].toString());
|
// domainAccessTokenType.set(jsonObject["token_type"].toString());
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DomainAccountManager::checkAndSignalForAccessToken() {
|
bool DomainAccountManager::checkAndSignalForAccessToken() {
|
||||||
|
|
|
@ -29,8 +29,9 @@ public:
|
||||||
QString getUsername() { return _username; }
|
QString getUsername() { return _username; }
|
||||||
QString getAccessToken() { return _access_token; }
|
QString getAccessToken() { return _access_token; }
|
||||||
QString getRefreshToken() { return _refresh_token; }
|
QString getRefreshToken() { return _refresh_token; }
|
||||||
|
QString getAuthedDomain() { return _domain_name; }
|
||||||
|
|
||||||
bool isLoggedIn() { return hasValidAccessToken(); }
|
bool isLoggedIn() { return !_authURL.isEmpty() && hasValidAccessToken(); }
|
||||||
|
|
||||||
Q_INVOKABLE bool checkAndSignalForAccessToken();
|
Q_INVOKABLE bool checkAndSignalForAccessToken();
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ private:
|
||||||
QString _username; // ####### TODO: Store elsewhere?
|
QString _username; // ####### TODO: Store elsewhere?
|
||||||
QString _access_token; // ####... ""
|
QString _access_token; // ####... ""
|
||||||
QString _refresh_token; // ####... ""
|
QString _refresh_token; // ####... ""
|
||||||
|
QString _domain_name; //
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DomainAccountManager_h
|
#endif // hifi_DomainAccountManager_h
|
||||||
|
|
Loading…
Reference in a new issue