wtforms / flask-wtf

Simple integration of Flask and WTForms, including CSRF, file upload and Recaptcha integration.
https://flask-wtf.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.46k stars 310 forks source link

Adding RECAPTCHA_DISABLE to disable recaptcha #509

Open rnt opened 2 years ago

rnt commented 2 years ago

This pull request allows you to use forms, without commenting on the recaptcha field when you are offline.

It's #214 but more than 6 years later. ;)

Checklist:

azmeuk commented 1 year ago

Thank you for your contribution. This looks OK to me. However I am wondering if RECAPTCHA_ENABLED with a default to True would not be better, to match with the other configuration vars (WTF_CSRF_ENABLED and WTF_I18N_ENABLED).

What do you think?

PanderMusubi commented 8 months ago

Perhaps as an alternative or for in the documentation, simply use:

if not app.debug:
    app.config['RECAPTCHA_PUBLIC_KEY'] = ...
    app.config['RECAPTCHA_PRIVATE_KEY'] = ...
    ...

    ...
    if not app.debug:
        recaptcha = RecaptchaField()
    submit = SubmitField('Submit')