feat: add captcha protection to user-facing forms#1000
feat: add captcha protection to user-facing forms#1000Ananya44444 wants to merge 3 commits intoalphaonelabs:mainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
WalkthroughAdded CAPTCHA fields to multiple form classes and updated several templates to render the new captcha inputs (plus an image preview size attribute in the meme form template). Changes are limited to form definitions and form templates for submission pages. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/forms.py`:
- Around line 581-582: Several forms (ReviewForm, ForumTopicForm, BlogPostForm,
MemeForm, StudyGroupForm, SurveyForm) currently always include the captcha field
("captcha" / CaptchaField) causing friction for logged-in users; update each
form's __init__ to accept and pop a "user" kwarg, call super().__init__(*args,
**kwargs), then if user and user.is_authenticated remove the captcha field (del
self.fields["captcha"]) just like TeachForm and MessageTeacherForm do, leaving
captcha enabled only when no authenticated user is provided.
There was a problem hiding this comment.
Pull request overview
This PR adds CAPTCHA protection to several user-facing Django forms to reduce spam and automated submissions across the platform.
Changes:
- Added
CaptchaField(widget=TailwindCaptchaTextInput)to 9 forms inweb/forms.py. - Extended CAPTCHA coverage to content creation and request flows (reviews, waiting rooms, forum topics, blog posts, memes, study groups, video requests, surveys, success stories).
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/templates/add_meme.html`:
- Around line 77-81: Update the CAPTCHA label and error markup to use the
project's Tailwind form label and danger styles: replace the label's class
(currently "block mb-2 font-medium") with "block text-sm font-medium
text-gray-700 dark:text-gray-300" for form.captcha.id_for_label, and change the
error paragraph's classes (currently "text-red-500 text-sm mt-1") to the
project's danger classes that include dark-mode variants (e.g., use the
project's danger color plus a dark: prefixed alternative) for the element
rendering form.captcha.errors.0 so both the label and error follow form-label
and dark-mode conventions.
In `@web/templates/web/forum/create_topic.html`:
- Around line 89-90: The CAPTCHA label in the template uses classes "block
text-sm font-medium mb-2" but is missing the repository standard form label
color classes; update the label for="{{ form.captcha.id_for_label }}" (the
CAPTCHA label element) to include "text-gray-700 dark:text-gray-300" so it
matches the standard "block text-sm font-medium text-gray-700
dark:text-gray-300" form-label convention.
In `@web/templates/web/forum/edit_topic.html`:
- Around line 69-71: The CAPTCHA label element (label for="{{
form.captcha.id_for_label }}") is missing the standard Tailwind text color
classes; update its class attribute to use the project's form-label classes by
adding "text-gray-700 dark:text-gray-300" so the full class becomes "block
text-sm font-medium text-gray-700 dark:text-gray-300" to match other form
labels.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
web/templates/add_meme.htmlweb/templates/success_stories/create.htmlweb/templates/videos/submit_request.htmlweb/templates/web/forum/create_topic.htmlweb/templates/web/forum/edit_topic.html
This PR adds CAPTCHA protection to 9 public-facing forms that were previously vulnerable to spam and automated bot submissions.
Forms Already having captcha
Changes Made
Forms with CAPTCHA Added:
Summary by CodeRabbit
New Features
UI