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:
|
def validate_session(self, session: str) -> bool:
|
||||||
"""Return True if session valid and make it longer valid."""
|
"""Return True if session valid and make it longer valid."""
|
||||||
if session not in self.sessions:
|
if session not in self.sessions:
|
||||||
|
_LOGGER.debug("Session %f is not known", session)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# check if timestamp valid, to avoid crash on malformed timestamp
|
# check if timestamp valid, to avoid crash on malformed timestamp
|
||||||
try:
|
try:
|
||||||
valid_until = utc_from_timestamp(self.sessions[session])
|
valid_until = utc_from_timestamp(self.sessions[session])
|
||||||
except OverflowError:
|
except OverflowError:
|
||||||
_LOGGER.warning("Session timestamp %f is invalid!", self.sessions[session])
|
self.sessions[session] = utcnow() + timedelta(minutes=15)
|
||||||
return False
|
return True
|
||||||
|
|
||||||
# Is still valid?
|
# Is still valid?
|
||||||
if valid_until < utcnow():
|
if valid_until < utcnow():
|
||||||
|
_LOGGER.debug("Session is no longer valid (%f/%f)", valid_until, utcnow())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Update time
|
# Update time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user