Revert "In registration flow If new sms requested then check and send redirected to two factor"

This commit is contained in:
Adam Shimali
2016-03-21 13:44:53 +00:00
parent 234fe387df
commit 792b42017a
4 changed files with 6 additions and 29 deletions

View File

@@ -41,7 +41,4 @@ def check_and_resend_verification_code():
# TODO there needs to be a way to generate a new session id
user = user_api_client.get_user_by_email(session['user_details']['email'])
user_api_client.send_verify_code(user.id, 'sms', user.mobile_number)
if user.state == 'pending':
return redirect(url_for('main.verify'))
else:
return redirect(url_for('main.two_factor'))
return redirect(url_for('main.two_factor'))

View File

@@ -17,7 +17,6 @@ from app.main.forms import TwoFactorForm
@main.route('/two-factor', methods=['GET', 'POST'])
def two_factor():
# TODO handle user_email not in session
try:
user_id = session['user_details']['id']
except KeyError:

View File

@@ -16,7 +16,7 @@
<p>
<a class="button" href="{{url_for('main.check_and_resend_verification_code')}}" role="button">Resend verification code</a>
<a class="button" href="send-new-code" role="button">Resend verification code</a>
</p>
</div>
</div>

View File

@@ -97,10 +97,10 @@ def test_should_render_verification_code_not_received(app_,
'speak to your service manager to reset the number.' in response.get_data(as_text=True)
def test_check_and_redirect_to_two_factor_if_user_active(app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code):
def test_check_and_redirect_to_two_factor(app_,
api_user_active,
mock_get_user_by_email,
mock_send_verify_code):
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
@@ -112,25 +112,6 @@ def test_check_and_redirect_to_two_factor_if_user_active(app_,
assert response.location == url_for('main.two_factor', _external=True)
def test_check_and_redirect_to_verify_if_user_pending(app_,
mocker,
api_user_pending,
mock_get_user_pending,
mock_send_verify_code):
mocker.patch('app.user_api_client.get_user_by_email', return_value=api_user_pending)
with app_.test_request_context():
with app_.test_client() as client:
with client.session_transaction() as session:
session['user_details'] = {
'id': api_user_pending.id,
'email': api_user_pending.email_address}
response = client.get(url_for('main.check_and_resend_verification_code'))
assert response.status_code == 302
assert response.location == url_for('main.verify', _external=True)
def test_should_create_new_code_for_user(app_,
api_user_active,
mock_get_user_by_email,