From 2b7e05d4e483bfe5514f77693f314f8d62a4dc24 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Tue, 5 May 2020 12:00:36 +0100 Subject: [PATCH] restore email sign in code expiry functionality reverts 789112a31f386c1db2378b2dcee8d16e31224735 however, keeps the changes to the tests as they were an improvement --- app/user/rest.py | 3 +-- tests/app/user/test_rest_verify.py | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/user/rest.py b/app/user/rest.py index a0a511340..e0115e57d 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -190,8 +190,7 @@ def verify_user_code(user_id): # only relevant from sms increment_failed_login_count(user_to_verify) raise InvalidRequest("Code not found", status_code=404) - # TODO: Fix email flow so that clicking link doesn't expire emails - if datetime.utcnow() > code.expiry_datetime or (code.code_used and data['code_type'] != 'email'): + if datetime.utcnow() > code.expiry_datetime or code.code_used: # sms and email increment_failed_login_count(user_to_verify) raise InvalidRequest("Code has expired", status_code=400) diff --git a/tests/app/user/test_rest_verify.py b/tests/app/user/test_rest_verify.py index a566c2940..8298391d6 100644 --- a/tests/app/user/test_rest_verify.py +++ b/tests/app/user/test_rest_verify.py @@ -453,10 +453,7 @@ def test_user_verify_email_code(admin_request, sample_user, auth_type): @pytest.mark.parametrize('code_type', [ - pytest.param( - EMAIL_TYPE, - marks=pytest.mark.xfail(raises=AssertionError, reason='Email code expiry disabled'), - ), + EMAIL_TYPE, SMS_TYPE ]) @freeze_time('2016-01-01T12:00:00')