mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
Merge pull request #269 from alphagov/invite-registration-sms-only
Change new invite registration flow to only need
This commit is contained in:
@@ -150,6 +150,23 @@ class TwoFactorForm(Form):
|
||||
raise ValidationError(reason)
|
||||
|
||||
|
||||
class VerifySmsForm(Form):
|
||||
def __init__(self, validate_code_func, *args, **kwargs):
|
||||
'''
|
||||
Keyword arguments:
|
||||
validate_code_func -- Validates the code with the API.
|
||||
'''
|
||||
self.validate_code_func = validate_code_func
|
||||
super(VerifySmsForm, self).__init__(*args, **kwargs)
|
||||
|
||||
sms_code = sms_code()
|
||||
|
||||
def validate_sms_code(self, field):
|
||||
is_valid, reason = self.validate_code_func(field.data, 'sms')
|
||||
if not is_valid:
|
||||
raise ValidationError(reason)
|
||||
|
||||
|
||||
class VerifyForm(Form):
|
||||
def __init__(self, validate_code_func, *args, **kwargs):
|
||||
'''
|
||||
|
||||
@@ -9,7 +9,10 @@ from flask_login import login_user
|
||||
|
||||
from app.main import main
|
||||
from app.main.dao import users_dao
|
||||
from app.main.forms import VerifyForm
|
||||
from app.main.forms import (
|
||||
VerifyForm,
|
||||
VerifySmsForm
|
||||
)
|
||||
|
||||
|
||||
@main.route('/verify', methods=['GET', 'POST'])
|
||||
@@ -22,7 +25,11 @@ def verify():
|
||||
def _check_code(code, code_type):
|
||||
return users_dao.check_verify_code(user_id, code, code_type)
|
||||
|
||||
form = VerifyForm(_check_code)
|
||||
if session.get('invited_user'):
|
||||
form = VerifySmsForm(_check_code)
|
||||
else:
|
||||
form = VerifyForm(_check_code)
|
||||
|
||||
if form.validate_on_submit():
|
||||
try:
|
||||
user = users_dao.get_user_by_id(user_id)
|
||||
|
||||
@@ -3,30 +3,48 @@
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block page_title %}
|
||||
Enter the codes we’ve sent you – GOV.UK Notify
|
||||
{% if form.email_code %}
|
||||
Enter the codes we’ve sent you – GOV.UK Notify
|
||||
{% else %}
|
||||
Enter the code we’ve sent you – GOV.UK Notify
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-two-thirds">
|
||||
<h1 class="heading-large">Enter the codes we’ve sent you</h1>
|
||||
<p>
|
||||
We’ve sent you confirmation codes by email and text message.
|
||||
</p>
|
||||
{% if form.email_code %}
|
||||
<h1 class="heading-large">Enter the codes we’ve sent you</h1>
|
||||
{% else %}
|
||||
<h1 class="heading-large">Enter the code we’ve sent you</h1>
|
||||
{% endif %}
|
||||
{% if form.email_code %}
|
||||
<p>
|
||||
We’ve sent you confirmation codes by email and text message.
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
We’ve sent you a confirmation code by text message.
|
||||
</p>
|
||||
{% endif %}
|
||||
<form autocomplete="off" method="post">
|
||||
{% if form.sms_code %}
|
||||
{{ textbox(
|
||||
form.sms_code,
|
||||
width='5em',
|
||||
help_link=url_for('.check_and_resend_text_code'),
|
||||
help_link_text='I haven’t received a text message'
|
||||
) }}
|
||||
{{ textbox(
|
||||
form.email_code,
|
||||
width='5em',
|
||||
help_link=url_for('.check_and_resend_email_code'),
|
||||
help_link_text='I haven’t received an email'
|
||||
) }}
|
||||
form.sms_code,
|
||||
width='5em',
|
||||
help_link=url_for('.check_and_resend_text_code'),
|
||||
help_link_text='I haven’t received a text message'
|
||||
) }}
|
||||
{% endif %}
|
||||
{% if form.email_code %}
|
||||
{{ textbox(
|
||||
form.email_code,
|
||||
width='5em',
|
||||
help_link=url_for('.check_and_resend_email_code'),
|
||||
help_link_text='I haven’t received an email'
|
||||
) }}
|
||||
{% endif %}
|
||||
{{ page_footer("Continue") }}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user