Skip to content

Commit 453a0bb

Browse files
authored
Revert "Use a generic form field" (#18653)
This reverts commit cab4073.
1 parent c4040af commit 453a0bb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

tests/unit/accounts/test_forms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def test_validate(self, metrics):
433433
"new_password": "mysupersecurepassword1!",
434434
"password_confirm": "mysupersecurepassword1!",
435435
"email": "[email protected]",
436-
"captcha_reponse": "",
436+
"g_recaptcha_reponse": "",
437437
}
438438
),
439439
user_service=user_service,
@@ -634,12 +634,12 @@ def test_recaptcha_disabled(self):
634634
assert not form.validate()
635635
# there shouldn't be any errors for the recaptcha field if it's
636636
# disabled
637-
assert not form.captcha_response.errors
637+
assert not form.g_recaptcha_response.errors
638638

639639
def test_recaptcha_required_error(self):
640640
form = forms.RegistrationForm(
641641
request=pretend.stub(),
642-
formdata=MultiDict({"captcha_response": ""}),
642+
formdata=MultiDict({"g_recaptcha_response": ""}),
643643
user_service=pretend.stub(),
644644
captcha_service=pretend.stub(
645645
enabled=True,
@@ -648,12 +648,12 @@ def test_recaptcha_required_error(self):
648648
breach_service=pretend.stub(check_password=lambda pw, tags=None: False),
649649
)
650650
assert not form.validate()
651-
assert form.captcha_response.errors.pop() == "Captcha error."
651+
assert form.g_recaptcha_response.errors.pop() == "Captcha error."
652652

653653
def test_recaptcha_error(self):
654654
form = forms.RegistrationForm(
655655
request=pretend.stub(),
656-
formdata=MultiDict({"captcha_response": "asd"}),
656+
formdata=MultiDict({"g_recaptcha_response": "asd"}),
657657
user_service=pretend.stub(),
658658
captcha_service=pretend.stub(
659659
verify_response=pretend.raiser(recaptcha.RecaptchaError),
@@ -662,7 +662,7 @@ def test_recaptcha_error(self):
662662
breach_service=pretend.stub(check_password=lambda pw, tags=None: False),
663663
)
664664
assert not form.validate()
665-
assert form.captcha_response.errors.pop() == "Captcha error."
665+
assert form.g_recaptcha_response.errors.pop() == "Captcha error."
666666

667667
def test_username_exists(self, pyramid_config):
668668
form = forms.RegistrationForm(

tests/unit/accounts/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ def _find_service(service=None, name=None, context=None):
17521752
"password_confirm": "MyStr0ng!shP455w0rd",
17531753
"email": "[email protected]",
17541754
"full_name": "full_name",
1755-
"captcha_response": "captchavalue",
1755+
"g_recaptcha_response": "captchavalue",
17561756
}
17571757
)
17581758

warehouse/accounts/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,15 @@ class RegistrationForm( # type: ignore[misc]
407407
PreventNullBytesValidator(),
408408
]
409409
)
410-
captcha_response = wtforms.StringField()
410+
g_recaptcha_response = wtforms.StringField()
411411

412412
def __init__(self, *args, captcha_service, user_service, **kwargs):
413413
super().__init__(*args, **kwargs)
414414
self.user_service = user_service
415415
self.user_id = None
416416
self.captcha_service = captcha_service
417417

418-
def validate_captcha_response(self, field):
418+
def validate_g_recaptcha_response(self, field):
419419
# do required data validation here due to enabled flag being required
420420
if self.captcha_service.enabled and not field.data:
421421
raise wtforms.validators.ValidationError("Captcha error.")

warehouse/templates/includes/input-captcha.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
{% if captcha_svc.enabled %}
55
<div class="{{ captcha_svc.class_name }}"
66
data-sitekey="{{ captcha_svc.site_key }}"></div>
7-
{% if form.captcha_response.errors %}
7+
{% if form.g_recaptcha_response.errors %}
88
<ul class="form-errors">
9-
{% for error in form.captcha_response.errors %}<li>{{ error }}</li>{% endfor %}
9+
{% for error in form.g_recaptcha_response.errors %}<li>{{ error }}</li>{% endfor %}
1010
</ul>
1111
{% endif %}
1212
{% endif %}

0 commit comments

Comments
 (0)