mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
In case user details were not in session the redirect did not use
url_for to redirect to sign in.
This commit is contained in:
@@ -19,7 +19,7 @@ def two_factor():
|
|||||||
try:
|
try:
|
||||||
user_id = session['user_details']['id']
|
user_id = session['user_details']['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect('main.sign_in')
|
return redirect(url_for('main.sign_in'))
|
||||||
|
|
||||||
def _check_code(code):
|
def _check_code(code):
|
||||||
return user_api_client.check_verify_code(user_id, code, "sms")
|
return user_api_client.check_verify_code(user_id, code, "sms")
|
||||||
|
|||||||
@@ -210,3 +210,15 @@ def test_two_factor_reset_login_count_called(app_,
|
|||||||
api_user_locked.reset_failed_login_count()
|
api_user_locked.reset_failed_login_count()
|
||||||
api_user_locked.password = new_password
|
api_user_locked.password = new_password
|
||||||
mock_update_user.assert_called_with(api_user_locked)
|
mock_update_user.assert_called_with(api_user_locked)
|
||||||
|
|
||||||
|
|
||||||
|
def test_two_factor_should_redirect_to_sign_in_if_user_not_in_session(app_,
|
||||||
|
api_user_active,
|
||||||
|
mock_get_user):
|
||||||
|
with app_.test_request_context():
|
||||||
|
with app_.test_client() as client:
|
||||||
|
|
||||||
|
response = client.post(url_for('main.two_factor'),
|
||||||
|
data={'sms_code': '12345'})
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert response.location == url_for('main.sign_in', _external=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user