diff --git a/resources/lib/connect/connectionmanager.py b/resources/lib/connect/connectionmanager.py index 6ddab3e5..5869cabe 100644 --- a/resources/lib/connect/connectionmanager.py +++ b/resources/lib/connect/connectionmanager.py @@ -317,6 +317,26 @@ class ConnectionManager(object): else: return server + def onAuthenticated(self, result, options={}): + + credentials = self.credentialProvider.getCredentials() + for s in credentials['Servers']: + if s['Id'] == result['ServerId']: + server = s + break + else: # Server not found? + return + + if options.get('updateDateLastAccessed') is not False: + server['DateLastAccessed'] = datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ') + + server['UserId'] = result['User']['Id'] + server['AccessToken'] = result['AccessToken'] + + self.credentialProvider.addOrUpdateServer(credentials['Servers'], server) + self._saveUserInfoIntoCredentials(server, result['User']) + self.credentialProvider.getCredentials(credentials) + def _tryConnect(self, url, timeout=None): url = self.getEmbyServerUrl(url, "system/info/public")