Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
WIP: Don't clear unused magic links when new ones are made
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Dec 1, 2024
1 parent 39d18d1 commit 171a470
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions config/envs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ class DefaultConfig(object):
"""
Magic Links
"""
MAGIC_LINK_EXPIRY_DAYS = 1
MAGIC_LINK_EXPIRY_SECONDS = 86400 * MAGIC_LINK_EXPIRY_DAYS
MAGIC_LINK_EXPIRY_SECONDS = 60 * 60 # last for an hour
MAGIC_LINK_RECORD_PREFIX = "link"
MAGIC_LINK_USER_PREFIX = "account"
MAGIC_LINK_LANDING_PAGE = "/service/magic-links/landing/"
Expand Down
8 changes: 5 additions & 3 deletions models/magic_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ def _make_link_json(account: Account, redirect_url: str):
(
datetime.now()
+ timedelta(
days=Config.MAGIC_LINK_EXPIRY_DAYS,
minutes=1,
seconds=Config.MAGIC_LINK_EXPIRY_SECONDS + 60,
)
).timestamp()
),
Expand All @@ -131,6 +130,7 @@ def _set_unique_keyed_record(self, value: str, prefix=None, max_tries: int = 6)
)
if created:
return prefixed_key, unique_key
return None

@staticmethod
def get_user_record_key(account_id: str):
Expand Down Expand Up @@ -189,7 +189,9 @@ def create_magic_link(
:return:
"""
current_app.logger.info(f"Creating magic link for {account}")
self.clear_existing_user_record(account.id)

# Don't clear unused magic links when a new one is made - for e2e tests sake 🙃
# self.clear_existing_user_record(account.id)

if not redirect_url:
redirect_url = urljoin(
Expand Down

0 comments on commit 171a470

Please sign in to comment.