Inform AccountManager about metaverse server change

This commit is contained in:
ksuprynowicz 2022-01-22 18:41:04 +01:00
parent bf48bf01c6
commit 30806ce346
5 changed files with 21 additions and 1 deletions

View file

@ -407,7 +407,11 @@ Item {
var url = metaverseServerField.text;
console.log("Setting metaverse server to", url);
Settings.setValue("private/selectedMetaverseURL", url);
setAuthURL(url);
//setAuthURL(url);
if(AccountServices.isLoggedIn()){
AccountServices.logOut();
}
AccountServices.updateAuthURLFromMetaverseServerURL();
}
linkAccountBody.login();
break;

View file

@ -72,6 +72,11 @@ void AccountServicesScriptingInterface::logOut() {
return accountManager->logout();
}
void AccountServicesScriptingInterface::updateAuthURLFromMetaverseServerURL() {
auto accountManager = DependencyManager::get<AccountManager>();
return accountManager->updateAuthURLFromMetaverseServerURL();
}
void AccountServicesScriptingInterface::loggedOut() {
emit AccountServicesScriptingInterface::disconnected(QString("logout"));
}

View file

@ -192,6 +192,12 @@ public slots:
* @function AccountServices.logOut
*/
void logOut();
/*@jsdoc
* Updates Metaverse Server URL in AccountManager. It's called by Login window after Metaverse Server URL is changed.
* @function AccountServices.updateAuthURLFromMetaverseServerURL
*/
void updateAuthURLFromMetaverseServerURL();
private slots:
void loggedOut();

View file

@ -205,6 +205,10 @@ void AccountManager::setAuthURL(const QUrl& authURL) {
}
}
void AccountManager::updateAuthURLFromMetaverseServerURL() {
setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL());
}
void AccountManager::setSessionID(const QUuid& sessionID) {
if (_sessionID != sessionID) {
qCDebug(networking) << "Metaverse session ID changed to" << uuidStringWithoutCurlyBraces(sessionID);

View file

@ -79,6 +79,7 @@ public:
const QUrl& getAuthURL() const { return _authURL; }
void setAuthURL(const QUrl& authURL);
bool hasAuthEndpoint() { return !_authURL.isEmpty(); }
Q_INVOKABLE void updateAuthURLFromMetaverseServerURL();
bool isLoggedIn() { return !_authURL.isEmpty() && hasValidAccessToken(); }
bool hasValidAccessToken();