A
A
Andrey Majidov2018-03-05 16:03:04
reCAPTCHA
Andrey Majidov, 2018-03-05 16:03:04

Flask-security + reCaptcha?

Question for flask and python experts:
How to embed reCaptcha (eg wtforms-recaptcha ) in flask-security ?

I registered the form field:

class ExtendedRegisterForm(RegisterForm):
    recaptcha = RecaptchaField(public_key='PUBLIC_KEY', private_key='PRIVATE_KEY', secure=True)

security = Security(app, user_datastore, register_form=ExtendedRegisterForm)


When trying to access the form page, it throws builtins.ValueError :
ValueError: IP address is required.

The Usage for wtforms-recaptcha has an example containing:
class CaptchaForm(Form):
    captcha = RecaptchaField(public_key=RECAPTCHA_PUB_KEY, private_key=RECAPTCHA_PRIV_KEY, secure=True)

form = CaptchaForm(request.POST, captcha={'ip_address': request.META['REMOTE_ADDR']})]})

but I don't understand where to insert the argument
captcha={'ip_address': request.META['REMOTE_ADDR']})]}
in the case of Flask-Security

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question