registration: fix phone form field validation (#78244) #74
|
@ -82,7 +82,7 @@ class RegistrationForm(HoneypotForm):
|
|||
|
||||
def clean(self):
|
||||
if app_settings.A2_ACCEPT_PHONE_AUTHENTICATION and get_user_model()._meta.get_field('phone'):
|
||||
if not self.cleaned_data['email'] and not self.cleaned_data['phone']:
|
||||
if not self.cleaned_data.get('email') and not self.cleaned_data.get('phone'):
|
||||
raise ValidationError(gettext('Please provide an email address or a mobile phone number.'))
|
||||
|
||||
|
||||
|
|
|
@ -958,6 +958,17 @@ def test_registration_no_identifier(app, db, settings):
|
|||
assert 'Please provide an email address or a mobile' in resp.text
|
||||
|
||||
|
||||
def test_registration_erroneous_phone_identifier(app, db, settings):
|
||||
settings.A2_ACCEPT_PHONE_AUTHENTICATION = True
|
||||
resp = app.get(reverse('registration_register'))
|
||||
resp.form.set('phone_1', 'thatsnotquiteit')
|
||||
resp = resp.form.submit()
|
||||
assert (
|
||||
"Phone number must be either in E.164 globally unique format or dialable from 33 country code (FR)."
|
||||
in resp.pyquery('.error')[0].text_content()
|
||||
)
|
||||
|
||||
|
||||
@urlmatch(netloc='foo.whatever.none')
|
||||
@remember_called
|
||||
def sms_service_mock(url, request):
|
||||
|
|
Loading…
Reference in New Issue