Update email_access_validated_at on link click

When someone uses a fresh password reset link they have proved that they
have access to their inbox.

At the moment, when revalidating a user’s email address we wait until
after they’ve put in the 2FA code before updating the timestamp which
records when they last validated their email address[1].

We can’t think of a good reason that we need the extra assurance of a
valid 2FA code to assert that the user has access to their email –
they’ve done that just by clicking the link. When the user clicks the
link we already update their failed login count before they 2fa. Think
it makes sense to handle `email_access_validated_at` then too.

As a bonus, the functional tests never go as far as getting a 2FA code
after a password reset[2], so the functional test user never gets its
timestamp updated. This causes the functional tests start failing after
90 days. By moving the update to this point we ensure that the
functional tests will keep passing indefinitely.

1. This code in the API (91542ad33e/app/dao/users_dao.py (L131))
   which is called by this code in the admin app (9ba37249a4/app/utils/login.py (L26))
2. 5837eb01dc/tests/functional/preview_and_dev/test_email_auth.py (L43-L46)
This commit is contained in:
Chris Hill-Scott
2021-08-17 16:14:47 +01:00
parent ff12ba689d
commit cb59413581
4 changed files with 27 additions and 4 deletions

View File

@@ -9,7 +9,8 @@ ALLOWED_ATTRIBUTES = {
'mobile_number',
'auth_type',
'updated_by',
'current_session_id'
'current_session_id',
'email_access_validated_at',
}