Commit 4ffd465f authored by Flavio TARSETTI's avatar Flavio TARSETTI

[accounts][models] make temporary url hash unique

parent 7fba594c
Pipeline #39876 passed with stage
in 14 minutes and 36 seconds
......@@ -160,15 +160,23 @@ def save_user_profile(sender, instance, **kwargs):
instance.profile.save()
def generate_url_hash():
# url_hash creation
url_hash = "".join(
random.choice(string.ascii_letters + string.digits) # nosec
for _ in range(TEMPORARY_URL_LENGTH)
)
return url_hash
class TemporaryUrlManager(models.Manager):
def create_temporary_url(self, status, supervision_track):
# Actions that result creating the object
# url_hash creation
url_hash = "".join(
random.choice(string.ascii_letters + string.digits) # nosec
for _ in range(TEMPORARY_URL_LENGTH)
)
url_hash = generate_url_hash()
used_hashes = [x.url_hash for x in TemporaryUrl.objects.all()]
while url_hash in used_hashes:
url_hash = generate_url_hash()
now = datetime.datetime.now()
expiration_date_delta = datetime.timedelta(
days=settings.ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment