diff --git a/app/main/__init__.py b/app/main/__init__.py index 4025b6dd1..021b5c086 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -3,4 +3,4 @@ from flask import Blueprint main = Blueprint('main', __name__) -from app.main.views import index, sign_in, register, two_factor, verify, sms, add_service +from app.main.views import index, sign_in, register, two_factor, verify, sms, add_service, code_not_received diff --git a/app/main/views/code_not_received.py b/app/main/views/code_not_received.py new file mode 100644 index 000000000..c07544bc7 --- /dev/null +++ b/app/main/views/code_not_received.py @@ -0,0 +1,23 @@ +from flask import render_template + +from app.main import main + + +@main.route("/email-not-received", methods=['GET']) +def email_not_received(): + return render_template('views/email-not-received.html') + + +@main.route('/email-not-received', methods=['POST']) +def check_and_resend_email_code(): + return None + + +@main.route("/text-not-received", methods=['GET']) +def text_not_received(): + return render_template('views/text-not-received.html') + + +@main.route('/text-not-received', methods=['POST']) +def check_and_resend_text_code(): + return None diff --git a/app/main/views/index.py b/app/main/views/index.py index 485b4d2d6..c9cdc41dd 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -35,16 +35,6 @@ def dashboard(): return render_template('views/dashboard.html') -@main.route("/email-not-received") -def emailnotreceived(): - return render_template('views/email-not-received.html') - - -@main.route("/text-not-received") -def textnotreceived(): - return render_template('views/text-not-received.html') - - @main.route("/send-email") def sendemail(): return render_template('views/send-email.html') diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index b2b4a34be..a5bb4f6c3 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -4,7 +4,6 @@ from flask import session from app.main import main from app.main.dao import users_dao from app.main.encryption import check_hash -from app.main.encryption import hashpw from app.main.forms import LoginForm from app.main.views import send_sms_code @@ -26,7 +25,7 @@ def process_sign_in(): if not user.is_active(): return jsonify(active_user=False), 401 if check_hash(form.password.data, user.password): - sms_code = send_sms_code(user.id, user.mobile_number) + send_sms_code(user.id, user.mobile_number) session['user_id'] = user.id else: users_dao.increment_failed_login_count(user.id) diff --git a/tests/app/main/views/test_code_not_received.py b/tests/app/main/views/test_code_not_received.py new file mode 100644 index 000000000..bab907fdd --- /dev/null +++ b/tests/app/main/views/test_code_not_received.py @@ -0,0 +1,18 @@ +def test_should_render_email_code_not_received_template(notifications_admin): + response = notifications_admin.test_client().get('/email-not-received') + assert response.status_code == 200 + assert 'Check your email address is correct and then resend the confirmation code' \ + in response.get_data(as_text=True) + + +# def test_should_check_and_resend_email_code(notifications_admin, notifications_admin_db, notify_db_session): +# response = notifications_admin.test_client().post('/email-not-received', +# data={'email_adddress': 'test@user.gov.uk'}) +# assert response is None + + +def test_should_render_text_code_not_received_template(notifications_admin): + response = notifications_admin.test_client().get('/text-not-received') + assert response.status_code == 200 + assert 'Check your mobile phone number is correct and then resend the confirmation code.' \ + in response.get_data(as_text=True)