diff --git a/connectionmanager.js b/connectionmanager.js index 940eb0c..28bac58 100644 --- a/connectionmanager.js +++ b/connectionmanager.js @@ -48,8 +48,9 @@ function mergeServers(credentialProvider, list1, list2) { function updateServerInfo(server, systemInfo) { - server.Name = systemInfo.ServerName; - + if (systemInfo.ServerName) { + server.Name = systemInfo.ServerName; + } if (systemInfo.Id) { server.Id = systemInfo.Id; } @@ -426,7 +427,14 @@ export default class ConnectionManager { apiClient.serverInfo(server); afterConnected(apiClient, options); - return onLocalUserSignIn(server, apiClient.serverAddress()); + return apiClient.getPublicSystemInfo().then(function (systemInfo) { + + updateServerInfo(server, systemInfo); + credentialProvider.addOrUpdateServer(credentials.Servers, server); + credentialProvider.credentials(credentials); + + return onLocalUserSignIn(server, apiClient.serverAddress()); + }); } function afterConnected(apiClient, options = {}) { @@ -574,7 +582,7 @@ export default class ConnectionManager { }).then(systemInfo => { updateServerInfo(server, systemInfo); - return Promise.resolve(); + return systemInfo; }, () => { @@ -1005,16 +1013,11 @@ export default class ConnectionManager { options = options || {}; - if (options.enableAutoLogin === false) { - - //server.UserId = null; - //server.AccessToken = null; - - } else if (verifyLocalAuthentication && server.AccessToken && options.enableAutoLogin !== false) { + if (verifyLocalAuthentication && server.AccessToken) { - validateAuthentication(server, serverUrl).then(() => { + validateAuthentication(server, serverUrl).then((fullSystemInfo) => { - afterConnectValidated(server, credentials, systemInfo, connectionMode, serverUrl, false, options, resolve); + afterConnectValidated(server, credentials, fullSystemInfo || systemInfo, connectionMode, serverUrl, false, options, resolve); }); return;