mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 22:56:31 +00:00
Adds more logs to session validation (#2219)
* Adds more logs to session validation * It's not there * Use debug * format * Create new timestamp if OverflowError
This commit is contained in:
parent
8f4ac10361
commit
934e59596a
@ -109,17 +109,19 @@ class Ingress(JsonConfig, CoreSysAttributes):
|
||||
def validate_session(self, session: str) -> bool:
|
||||
"""Return True if session valid and make it longer valid."""
|
||||
if session not in self.sessions:
|
||||
_LOGGER.debug("Session %f is not known", session)
|
||||
return False
|
||||
|
||||
# check if timestamp valid, to avoid crash on malformed timestamp
|
||||
try:
|
||||
valid_until = utc_from_timestamp(self.sessions[session])
|
||||
except OverflowError:
|
||||
_LOGGER.warning("Session timestamp %f is invalid!", self.sessions[session])
|
||||
return False
|
||||
self.sessions[session] = utcnow() + timedelta(minutes=15)
|
||||
return True
|
||||
|
||||
# Is still valid?
|
||||
if valid_until < utcnow():
|
||||
_LOGGER.debug("Session is no longer valid (%f/%f)", valid_until, utcnow())
|
||||
return False
|
||||
|
||||
# Update time
|
||||
|
Loading…
x
Reference in New Issue
Block a user