mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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();
|
||||
bool isMetaverseLoggedIn = accountManager->isLoggedIn();
|
||||
bool isDomainLoggedIn = domainAccountManager->isLoggedIn();
|
||||
qCDebug(interfaceapp) << "Is Logged Into Domain:" << isDomainLoggedIn;
|
||||
QString authedDomain = domainAccountManager->getAuthedDomain();
|
||||
|
||||
QString buildVersion = " - Vircadia - "
|
||||
+ (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build"))
|
||||
|
@ -7095,8 +7095,7 @@ void Application::updateWindowTitle() const {
|
|||
nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)";
|
||||
|
||||
QString metaverseUsername = accountManager->getAccountInfo().getUsername();
|
||||
// ###### TODO
|
||||
// QString domainUsername = domainAccountManager->getUsername();
|
||||
QString domainUsername = domainAccountManager->getUsername();
|
||||
|
||||
setCrashAnnotation("sentry[user][metaverseUsername]", metaverseUsername.toStdString());
|
||||
|
||||
|
@ -7122,10 +7121,10 @@ void Application::updateWindowTitle() const {
|
|||
}
|
||||
|
||||
QString domainDetails;
|
||||
if (isDomainLoggedIn) {
|
||||
if (currentPlaceName == authedDomain && isDomainLoggedIn) {
|
||||
// ###### TODO
|
||||
// domainDetails = "Domain: Logged in as " + domainUsername;
|
||||
domainDetails = "Domain: Logged In";
|
||||
domainDetails = "Domain: Logged in as " + domainUsername;
|
||||
} else {
|
||||
domainDetails = "Domain: Not Logged In";
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <DependencyManager.h>
|
||||
|
||||
#include "NodeList.h"
|
||||
#include "NetworkingConstants.h"
|
||||
#include "NetworkLogging.h"
|
||||
#include "NetworkAccessManager.h"
|
||||
|
@ -101,6 +103,8 @@ void DomainAccountManager::requestAccessTokenFinished() {
|
|||
// miniOrange plugin provides no scope.
|
||||
if (rootObject.contains("access_token")) {
|
||||
// Success.
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
_domain_name = nodeList->getDomainHandler().getHostname();
|
||||
QUrl rootURL = requestReply->url();
|
||||
rootURL.setPath("");
|
||||
setTokensFromJSON(rootObject, rootURL);
|
||||
|
@ -133,10 +137,12 @@ bool DomainAccountManager::accessTokenIsExpired() {
|
|||
|
||||
|
||||
bool DomainAccountManager::hasValidAccessToken() {
|
||||
QString currentDomainAccessToken = domainAccessToken.get();
|
||||
|
||||
if (currentDomainAccessToken.isEmpty() || accessTokenIsExpired()) {
|
||||
// ###### 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();
|
||||
QString currentDomainAccessToken = _access_token;
|
||||
|
||||
// if (currentDomainAccessToken.isEmpty() || accessTokenIsExpired()) {
|
||||
if (currentDomainAccessToken.isEmpty()) {
|
||||
if (VERBOSE_HTTP_REQUEST_DEBUGGING) {
|
||||
qCDebug(networking) << "An access token is required for requests to"
|
||||
<< qPrintable(_authURL.toString());
|
||||
|
@ -153,23 +159,20 @@ bool DomainAccountManager::hasValidAccessToken() {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DomainAccountManager::setTokensFromJSON(const QJsonObject& jsonObject, const QUrl& url) {
|
||||
_access_token = jsonObject["access_token"].toString();
|
||||
_refresh_token = jsonObject["refresh_token"].toString();
|
||||
|
||||
// ####### TODO: Enable and use these.
|
||||
// ####### TODO: Protect these per AccountManager?
|
||||
// ######: TODO: clientID needed?
|
||||
/*
|
||||
qCDebug(networking) << "Storing a domain account with access-token for" << qPrintable(url.toString());
|
||||
domainAccessToken.set(jsonObject["access_token"].toString());
|
||||
domainAccessRefreshToken.set(jsonObject["refresh_token"].toString());
|
||||
domainAccessTokenExpiresIn.set(QDateTime::currentMSecsSinceEpoch() + (jsonObject["expires_in"].toDouble() * 1000));
|
||||
domainAccessTokenType.set(jsonObject["token_type"].toString());
|
||||
*/
|
||||
|
||||
// qCDebug(networking) << "Storing a domain account with access-token for" << qPrintable(url.toString());
|
||||
// domainAccessToken.set(jsonObject["access_token"].toString());
|
||||
// domainAccessRefreshToken.set(jsonObject["refresh_token"].toString());
|
||||
// domainAccessTokenExpiresIn.set(QDateTime::currentMSecsSinceEpoch() + (jsonObject["expires_in"].toDouble() * 1000));
|
||||
// domainAccessTokenType.set(jsonObject["token_type"].toString());
|
||||
}
|
||||
|
||||
bool DomainAccountManager::checkAndSignalForAccessToken() {
|
||||
|
|
|
@ -29,8 +29,9 @@ public:
|
|||
QString getUsername() { return _username; }
|
||||
QString getAccessToken() { return _access_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();
|
||||
|
||||
|
@ -59,6 +60,7 @@ private:
|
|||
QString _username; // ####### TODO: Store elsewhere?
|
||||
QString _access_token; // ####... ""
|
||||
QString _refresh_token; // ####... ""
|
||||
QString _domain_name; //
|
||||
};
|
||||
|
||||
#endif // hifi_DomainAccountManager_h
|
||||
|
|
Loading…
Reference in a new issue