mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[core] Validate session expiry time before skipping login
This commit is contained in:
parent
5d4beeb27d
commit
aafba86a94
|
@ -180,8 +180,16 @@ class LegendaryCore:
|
||||||
"""
|
"""
|
||||||
if not self.lgd.userdata:
|
if not self.lgd.userdata:
|
||||||
raise ValueError('No saved credentials')
|
raise ValueError('No saved credentials')
|
||||||
elif self.logged_in:
|
elif self.logged_in and self.lgd.userdata['expires_at']:
|
||||||
|
dt_exp = datetime.fromisoformat(self.lgd.userdata['expires_at'][:-1])
|
||||||
|
dt_now = datetime.utcnow()
|
||||||
|
td = dt_now - dt_exp
|
||||||
|
|
||||||
|
# if session still has at least 10 minutes left we can re-use it.
|
||||||
|
if dt_exp > dt_now and abs(td.total_seconds()) > 600:
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
self.logged_in = False
|
||||||
|
|
||||||
# run update check
|
# run update check
|
||||||
if self.update_check_enabled():
|
if self.update_check_enabled():
|
||||||
|
|
Loading…
Reference in a new issue