mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Update token/user for connect module
This commit is contained in:
parent
0635990d67
commit
9411ff14ce
4 changed files with 20 additions and 22 deletions
|
@ -645,26 +645,6 @@ class ConnectionManager(object):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
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 _onConnectUserSignIn(self, user):
|
def _onConnectUserSignIn(self, user):
|
||||||
|
|
||||||
self.connectUser = user
|
self.connectUser = user
|
||||||
|
|
|
@ -177,3 +177,7 @@ class ConnectManager(object):
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("User is not authenticated")
|
raise RuntimeError("User is not authenticated")
|
||||||
|
|
||||||
|
def update_token(self, servers, server):
|
||||||
|
self._connect.credentialProvider.addOrUpdateServer(servers, server)
|
||||||
|
self.update_state()
|
||||||
|
|
|
@ -91,10 +91,15 @@ class InitialSetup(object):
|
||||||
if settings('server'):
|
if settings('server'):
|
||||||
current_state = self.connectmanager.get_state()
|
current_state = self.connectmanager.get_state()
|
||||||
for server in current_state['Servers']:
|
for server in current_state['Servers']:
|
||||||
|
|
||||||
if server['Id'] == settings('serverId'):
|
if server['Id'] == settings('serverId'):
|
||||||
|
# Update token
|
||||||
|
server['UserId'] = settings('userId') or None
|
||||||
|
server['AccessToken'] = settings('token') or None
|
||||||
|
self.connectmanager.update_token(current_state['Servers'], server)
|
||||||
|
|
||||||
server_address = self.connectmanager.get_address(server)
|
server_address = self.connectmanager.get_address(server)
|
||||||
self._set_server(server_address, server)
|
self._set_server(server_address, server)
|
||||||
#self._set_user(server['UserId'], server['AccessToken'])
|
|
||||||
log.info("Found server!")
|
log.info("Found server!")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class UserClient(threading.Thread):
|
||||||
self.doutils = downloadutils.DownloadUtils()
|
self.doutils = downloadutils.DownloadUtils()
|
||||||
self.download = self.doutils.downloadUrl
|
self.download = self.doutils.downloadUrl
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
self.connectmanager = connectmanager.ConnectManager()
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@ class UserClient(threading.Thread):
|
||||||
user_found = user
|
user_found = user
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
user = connectmanager.ConnectManager().login_manual(server, user_found)
|
user = self.connectmanager.login_manual(server, user_found)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
window('emby_serverStatus', value="stop")
|
window('emby_serverStatus', value="stop")
|
||||||
self._auth = False
|
self._auth = False
|
||||||
|
@ -246,6 +247,14 @@ class UserClient(threading.Thread):
|
||||||
self._user = None
|
self._user = None
|
||||||
self.auth = None
|
self.auth = None
|
||||||
|
|
||||||
|
current_state = self.connectmanager.get_state()
|
||||||
|
for server in current_state['Servers']:
|
||||||
|
|
||||||
|
if server['Id'] == settings('serverId'):
|
||||||
|
# Update token
|
||||||
|
server['AccessToken'] = None
|
||||||
|
self.connectmanager.update_token(current_state['Servers'], server)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
monitor = xbmc.Monitor()
|
monitor = xbmc.Monitor()
|
||||||
|
|
Loading…
Reference in a new issue