Skip to content

Add reCAPTCHA enforcement to forgot-password reset requests#156

Open
Copilot wants to merge 3 commits intomainfrom
copilot/add-captcha-for-password-reset
Open

Add reCAPTCHA enforcement to forgot-password reset requests#156
Copilot wants to merge 3 commits intomainfrom
copilot/add-captcha-for-password-reset

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 15, 2026

Bots were able to automate password reset submissions because /forgot-password had no CAPTCHA gate on submit. This change adds reCAPTCHA validation to the forgot-password flow so reset emails are only processed after human verification.

  • Controller: enforce CAPTCHA on reset request

    • Added reCAPTCHA verification in forgot_password_post before email-service and user lookup logic.
    • On failed verification, the handler returns the forgot-password form with a clear validation error.
  • UI: render CAPTCHA on forgot-password form

    • Added reCAPTCHA widget to templates/password_reset/forgot.html when RECAPTCHA_SITEKEY is configured.
    • Added accessible labeling/grouping around the CAPTCHA block.
  • Focused coverage

    • Added tests/test_password_reset_captcha.py to validate:
      • invalid CAPTCHA blocks processing
      • valid CAPTCHA allows normal reset-request flow
# app/controllers/password_reset.py
if not verify_recaptcha(request):
    flash('Verification failed. Please complete the challenge and try again.', FLASH_ERROR)
    return render_template('password_reset/forgot.html')

Copilot AI linked an issue Apr 15, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add captcha to password reset functionality Add reCAPTCHA enforcement to forgot-password reset requests Apr 15, 2026
Copilot AI requested a review from AsyncFor April 15, 2026 19:05
@AsyncFor AsyncFor marked this pull request as ready for review April 15, 2026 19:05
@AsyncFor AsyncFor requested a review from xusheng6 April 15, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add captcha for password reset

2 participants