From 1acfd78cdf194173a1198db6896a07af8fddae3d Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Mon, 4 May 2015 19:03:46 -0500 Subject: [PATCH] Added reset auth option to settings --- default.py | 10 ++++++++++ resources/lib/UserClient.py | 9 +++++---- resources/settings.xml | 9 ++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/default.py b/default.py index 5d7f64c0..d5e7068d 100644 --- a/default.py +++ b/default.py @@ -44,8 +44,18 @@ if mode == "play" or mode == "playfromaddon": item = PlaybackUtils().PLAY(result, setup="default") elif mode == "reset": + # User reset local Kodi db utils.reset() +elif mode == "resetauth": + # User tried login and failed too many times + resp = xbmcgui.Dialog().yesno("Warning", "Emby might lock your account if you fail to log in too many times. Proceed anyway?") + if resp == 1: + xbmc.log("Reset login attempts.") + WINDOW.setProperty("Server_status", "Auth") + else: + xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') + elif mode == "nextup": #if the addon is called with nextup parameter, we return the nextepisodes list of the given tagname diff --git a/resources/lib/UserClient.py b/resources/lib/UserClient.py index 2bef61f0..f801627b 100644 --- a/resources/lib/UserClient.py +++ b/resources/lib/UserClient.py @@ -116,7 +116,7 @@ class UserClient(threading.Thread): username = self.getUsername() w_token = self.WINDOW.getProperty('accessToken%s' % username) - s_token = self.addon.getSetting('accessToken%s' % username) + s_token = self.addon.getSetting('accessToken') # Verify the window property if (w_token != ""): @@ -272,7 +272,7 @@ class UserClient(threading.Thread): if (result != None and accessToken != None): self.currUser = username userId = result[u'User'][u'Id'] - addon.setSetting("accessToken%s" % username, accessToken) + addon.setSetting("accessToken", accessToken) addon.setSetting("userId%s" % username, userId) self.logMsg("User Authenticated: %s" % accessToken) self.loadCurrUser() @@ -281,15 +281,16 @@ class UserClient(threading.Thread): return else: self.logMsg("User authentication failed.") - addon.setSetting("accessToken%s" % username, "") + addon.setSetting("accessToken", "") addon.setSetting("userId%s" % username, "") xbmcgui.Dialog().ok("Error connecting", "Invalid username or password.") # Give two attempts at entering password self.retry += 1 if self.retry == 2: - self.logMsg("Too many retries. Please restart Kodi.") + self.logMsg("Too many retries. You can retry by selecting the option in the addon settings.") self.WINDOW.setProperty("Server_status", "Stop") + xbmcgui.Dialog().ok("Error connecting", "Failed to authenticate too many times. You can retry by selecting the option in the addon settings.") self.auth = False return diff --git a/resources/settings.xml b/resources/settings.xml index a58bea71..3d94fb99 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -3,13 +3,16 @@ - + + + + @@ -21,8 +24,8 @@ - - + +