From ce28ce2914096224965e66439ea97df91595783a Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 17 Apr 2020 11:35:39 +0200 Subject: [PATCH] [core] Fix session reuse not checking if expiry is after now Since total_seconds() just returns a positive number with the difference we have to make sure we're actually still before the expiry time. --- legendary/__init__.py | 2 +- legendary/core.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/legendary/__init__.py b/legendary/__init__.py index eab1ff5..baebb4b 100644 --- a/legendary/__init__.py +++ b/legendary/__init__.py @@ -1,3 +1,3 @@ """Legendary!""" -__version__ = '0.0.1' +__version__ = '0.0.2' diff --git a/legendary/core.py b/legendary/core.py index 593a85e..0c708c0 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -98,7 +98,7 @@ class LegendaryCore: td = dt_now - dt_old # if session still has at least 10 minutes left we can re-use it. - if td.total_seconds() < (self.lgd.userdata['expires_in'] - 600): + if dt_old > dt_now and td.total_seconds() < (self.lgd.userdata['expires_in'] - 600): self.log.debug('Reusing existing login session...') self.egs.resume_session(self.lgd.userdata) return True