Add a second URL for the email auth endpoint

We’re going to add an interstitial page that redirects to this new URL.
But we don’t want that redirect to 404 while the change is deploying,
because some boxes will have the new URL and some won’t. So let’s deploy
the new URL to all the boxes first, then the redirect page can safely
take over the new one.

The new URL is going to be `post` not `get` because that feels more
HTTP-y, so we need to make sure that’s part of this change too.
This commit is contained in:
Chris Hill-Scott
2020-05-04 12:37:05 +01:00
parent 0f3e0409db
commit ae2f8f9887
2 changed files with 6 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ def two_factor_email_sent():
)
@main.route('/email-auth/<token>', methods=['GET'])
@main.route('/email-auth/<token>', methods=['GET', 'POST'])
def two_factor_email(token):
if current_user.is_authenticated:
return redirect_when_logged_in(platform_admin=current_user.platform_admin)

View File

@@ -253,6 +253,9 @@ def test_two_factor_should_activate_pending_user(
assert mock_activate_user.called
@pytest.mark.parametrize('http_method', (
'get', 'post',
))
def test_valid_two_factor_email_link_logs_in_user(
client,
valid_token,
@@ -260,10 +263,11 @@ def test_valid_two_factor_email_link_logs_in_user(
mock_get_services_with_one_service,
mocker,
mock_create_event,
http_method,
):
mocker.patch('app.user_api_client.check_verify_code', return_value=(True, ''))
response = client.get(
response = getattr(client, http_method)(
url_for_endpoint_with_token('main.two_factor_email', token=valid_token),
)