diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 871800ea1c..43013eb61e 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -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; diff --git a/interface/src/scripting/AccountServicesScriptingInterface.cpp b/interface/src/scripting/AccountServicesScriptingInterface.cpp index 34f33903e2..87aacad631 100644 --- a/interface/src/scripting/AccountServicesScriptingInterface.cpp +++ b/interface/src/scripting/AccountServicesScriptingInterface.cpp @@ -72,6 +72,11 @@ void AccountServicesScriptingInterface::logOut() { return accountManager->logout(); } +void AccountServicesScriptingInterface::updateAuthURLFromMetaverseServerURL() { + auto accountManager = DependencyManager::get(); + return accountManager->updateAuthURLFromMetaverseServerURL(); +} + void AccountServicesScriptingInterface::loggedOut() { emit AccountServicesScriptingInterface::disconnected(QString("logout")); } diff --git a/interface/src/scripting/AccountServicesScriptingInterface.h b/interface/src/scripting/AccountServicesScriptingInterface.h index 00c17db380..723622523c 100644 --- a/interface/src/scripting/AccountServicesScriptingInterface.h +++ b/interface/src/scripting/AccountServicesScriptingInterface.h @@ -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(); diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 9e4cb01e45..514efb431f 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -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); diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index bd318e3af5..ad8a92a187 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -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();