You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Recaptcha validator grabs a specific field by name instead of using field.data (link to line below). This means that an HTML form must send the recaptcha value as g-recaptcha-response or the validator fails. Our frontend is a react app that does not use wtforms to generate the HTML. And uses the actual form field names inside POST data.
classTokenForm(Form):
"""Evaluate login attempts with optional recaptcha."""email=StringField(validators=[validators.DataRequired()])
password=StringField(validators=[validators.DataRequired()])
recaptcha=RecaptchaField()
If the form data is passed as {... "recaptcha": "recaptcha_response_value"}, the validator fails even though it has the data in the passed field instance.
Our REST api and frontend rely on field names matching. Is there a workaround for this?
The text was updated successfully, but these errors were encountered:
fromflask_wtf.recaptchaimportRecaptchadefvalidate_recaptcha(form, field):
"""Validate recaptcha response."""# Recaptcha validator only looks for data in a hard-coded field name# https://github.com/lepture/flask-wtf/issues/370request.json["g-recaptcha-response"] =field.datareturnRecaptcha()(form, field)
The Recaptcha validator grabs a specific field by name instead of using
field.data
(link to line below). This means that an HTML form must send the recaptcha value asg-recaptcha-response
or the validator fails. Our frontend is a react app that does not use wtforms to generate the HTML. And uses the actual form field names inside POST data.https://github.com/lepture/flask-wtf/blob/master/flask_wtf/recaptcha/validators.py#L40
If the form data is passed as
{... "recaptcha": "recaptcha_response_value"}
, the validator fails even though it has the data in the passedfield
instance.Our REST api and frontend rely on field names matching. Is there a workaround for this?
The text was updated successfully, but these errors were encountered: