confirmation: Use expiry_date to verify validity.

This commit is contained in:
Mateusz Mandera 2021-08-02 20:55:16 +02:00 committed by Tim Abbott
parent 18ad18c025
commit de5fc7826b
1 changed files with 1 additions and 2 deletions

View File

@ -70,8 +70,7 @@ def get_object_from_key(
except Confirmation.DoesNotExist: except Confirmation.DoesNotExist:
raise ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST) raise ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST)
time_elapsed = timezone_now() - confirmation.date_sent if timezone_now() > confirmation.expiry_date:
if time_elapsed.total_seconds() > _properties[confirmation.type].validity_in_days * 24 * 3600:
raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED) raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED)
obj = confirmation.content_object obj = confirmation.content_object