fix: get_expires_in logic for token cache
This commit is contained in:
parent
9d6f82725e
commit
52daef0dfd
1 changed files with 3 additions and 4 deletions
|
|
@ -52,11 +52,10 @@ class TokenCache(Document):
|
|||
return self
|
||||
|
||||
def get_expires_in(self):
|
||||
modified = frappe.utils.get_datetime(self.modified)
|
||||
expiry_utc = modified.astimezone(pytz.utc) + timedelta(seconds=self.expires_in)
|
||||
now_utc = datetime.utcnow().replace(tzinfo=pytz.utc)
|
||||
expiry_time = frappe.utils.get_datetime(self.modified) + timedelta(seconds=self.expires_in)
|
||||
expiry_local = expiry_time.replace(tzinfo=pytz.timezone(frappe.utils.get_time_zone()))
|
||||
expiry_utc = expiry_local.astimezone(pytz.utc)
|
||||
return (expiry_utc - now_utc).total_seconds()
|
||||
return cint((expiry_utc - now_utc).total_seconds())
|
||||
|
||||
def is_expired(self):
|
||||
return self.get_expires_in() < 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue