diff --git a/connectionmanager.js b/connectionmanager.js index 378484a..8c7655e 100644 --- a/connectionmanager.js +++ b/connectionmanager.js @@ -567,30 +567,7 @@ export default class ConnectionManager { }).then(systemInfo => { updateServerInfo(server, systemInfo); - - if (server.UserId) { - - return ajax({ - type: "GET", - url: getEmbyServerUrl(url, `users/${server.UserId}`), - dataType: "json", - headers: { - "X-MediaBrowser-Token": server.AccessToken - } - - }).then(user => { - - return onLocalUserSignIn(server, connectionMode, user); - - }, () => { - - server.UserId = null; - server.AccessToken = null; - return Promise.resolve(); - }); - } else { - return Promise.resolve(); - } + return Promise.resolve(); }, () => { @@ -1096,13 +1073,22 @@ export default class ConnectionManager { result.ApiClient.updateServerInfo(server, connectionMode); + const resolveActions = function () { + resolve(result); + + events.trigger(self, 'connected', [result]); + }; + if (result.State === 'SignedIn') { afterConnected(result.ApiClient, options); - } - - resolve(result); - events.trigger(self, 'connected', [result]); + result.ApiClient.getCurrentUser().then(function (user) { + onLocalUserSignIn(server, connectionMode, user).then(resolveActions, resolveActions); + }, resolveActions); + } + else { + resolveActions(); + } } self.connectToAddress = function (address, options) {