From b3b54709470458b608ef7a297170caf5c7ef9a5a Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 8 Oct 2021 10:15:07 +0200 Subject: [PATCH] [core] Make auth() return immediately if already logged in --- legendary/core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/legendary/core.py b/legendary/core.py index 85af238..d30e924 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -86,6 +86,7 @@ class LegendaryCore: self.update_available = False self.force_show_update = False self.webview_killswitch = False + self.logged_in = False def auth(self, username, password): """ @@ -179,6 +180,8 @@ class LegendaryCore: """ if not self.lgd.userdata: raise ValueError('No saved credentials') + elif self.logged_in: + return True # run update check if self.update_check_enabled(): @@ -199,6 +202,7 @@ class LegendaryCore: self.log.info('Trying to re-use existing login session...') try: self.egs.resume_session(self.lgd.userdata) + self.logged_in = True return True except InvalidCredentialsError as e: self.log.warning(f'Resuming failed due to invalid credentials: {e!r}') @@ -219,6 +223,7 @@ class LegendaryCore: return False self.lgd.userdata = userdata + self.logged_in = True return True def update_check_enabled(self):