mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 08:28:26 -04:00
check users' session id.
when a user enters their 2FA code, the API will store a random UUID
against them in the database - this code is then stored on the cookie
on the front end.
At the beginning of each authenticated request, we do the following
steps:
* Retrieve the user's cookie, and get the user_id from it
* Request that user's details from the database
* populate current_user with the DB model
* run the login_required decorator, which calls
current_user.is_authenticated
is_authenticated now also checks that the database model matches the
cookie for session_id. The potential states and meanings are as follows:
database | cookie | meaning
----------+--------+---------
None | None | New user, or system just been deployed.
| | Redirect to start page.
----------+--------+---------
'abc' | None | New browser (or cleared cookies). Redirect to
| | start page.
----------+--------+---------
None | 'abc' | Invalid state (cookie is set from user obj, so
| | would only happen if DB is cleared)
----------+--------+---------
'abc' | 'abc' | Same browser. Business as usual
----------+--------+---------
'abc' | 'def' | Different browser in cookie - db has been changed
| | since then. Redirect to start
This commit is contained in:
@@ -80,7 +80,7 @@ def test_if_existing_user_accepts_twice_they_redirect_to_sign_in(
|
||||
page.select('main p')[0].text.strip(),
|
||||
) == (
|
||||
'You need to sign in again',
|
||||
'We sign you out if you haven’t used Notify for a while.',
|
||||
'We signed you out because you haven’t used Notify for a while.',
|
||||
)
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ def test_existing_user_of_service_get_redirected_to_signin(
|
||||
page.select('main p')[0].text.strip(),
|
||||
) == (
|
||||
'You need to sign in again',
|
||||
'We sign you out if you haven’t used Notify for a while.',
|
||||
'We signed you out because you haven’t used Notify for a while.',
|
||||
)
|
||||
assert mock_accept_invite.call_count == 1
|
||||
|
||||
@@ -141,7 +141,7 @@ def test_existing_signed_out_user_accept_invite_redirects_to_sign_in(
|
||||
page.select('main p')[0].text.strip(),
|
||||
) == (
|
||||
'You need to sign in again',
|
||||
'We sign you out if you haven’t used Notify for a while.',
|
||||
'We signed you out because you haven’t used Notify for a while.',
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user