Skip to content

Commit

Permalink
Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
na-stewart committed Jun 21, 2024
1 parent e8cf716 commit 647df58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sanic_security/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
NotFoundError,
CredentialsError,
DeactivatedError,
SecondFactorFulfilledError, ExpiredError, RequiredRefreshError,
SecondFactorFulfilledError,
ExpiredError,
RequiredRefreshError,
)
from sanic_security.models import Account, AuthenticationSession, Role, TwoStepSession
from sanic_security.utils import get_ip
Expand Down
6 changes: 5 additions & 1 deletion sanic_security/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ class AuthenticationSession(Session):
requires_second_factor (bool): Determines if session requires a second factor.
refresh_expiration_date (bool): Date and time the session can no longer be refreshed.
"""

refreshed: bool = fields.BooleanField(default=False)
requires_second_factor: bool = fields.BooleanField(default=False)
refresh_expiration_date: datetime.datetime = fields.DatetimeField(null=True)
Expand Down Expand Up @@ -580,7 +581,10 @@ async def refresh(self, request: Request):
self.validate()
raise NotExpiredError()
except ExpiredError as e:
if datetime.datetime.now(datetime.timezone.utc) <= self.refresh_expiration_date:
if (
datetime.datetime.now(datetime.timezone.utc)
<= self.refresh_expiration_date
):
self.active = False
self.refreshed = True
await self.save(update_fields=["active", "refreshed"])
Expand Down

0 comments on commit 647df58

Please sign in to comment.