Skip to content

OTWO-7704 Rate-limiting on password reset request - #1933

Open
bd-vaibhav wants to merge 1 commit into
stagingfrom
OTWO-7704
Open

OTWO-7704 Rate-limiting on password reset request#1933
bd-vaibhav wants to merge 1 commit into
stagingfrom
OTWO-7704

Conversation

@bd-vaibhav

Copy link
Copy Markdown
Contributor

No description provided.

@bd-vaibhav
bd-vaibhav requested review from Niharika1117 and Priya5 and a lite review from Copilot August 5, 2026 07:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds account-level rate limiting for password reset requests to reduce abuse, including persistence for rate-limit state, controller enforcement, user-facing messaging, and controller test coverage.

Changes:

  • Adds password_reset_count and password_reset_requested_at columns to accounts to persist rate-limit state.
  • Introduces cooldown + rolling-window enforcement around PasswordResetsController#create, and records reset-request attempts.
  • Expands controller tests and adds i18n strings for rate-limit error messaging.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
test/controllers/password_resets_controller_test.rb Adds boundary/behavior tests for cooldown and rolling-window limits.
db/migrate/20260804172050_add_password_reset_rate_limit_to_accounts.rb Adds persistent counters/timestamps needed for per-account rate limiting.
config/locales/en.yml Adds i18n strings for password reset rate-limit messages and template-relative keys.
app/controllers/password_resets_controller.rb Implements rate-limit checks and request recording around password reset creation.
Suppressed comments (1)

test/controllers/password_resets_controller_test.rb:66

  • The example says it resets the counter "at exactly 10 minute boundary" but the time travel uses 10.minutes + 1.second. This misses the exact boundary condition your controller logic depends on (last > RESET_WINDOW.ago).
      travel_to base_time + 10.minutes + 1.second do

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/controllers/password_resets_controller.rb
Comment thread app/controllers/password_resets_controller.rb Outdated
Comment thread app/controllers/password_resets_controller.rb
Comment thread test/controllers/password_resets_controller_test.rb
Comment thread test/controllers/password_resets_controller_test.rb Outdated
@bd-vaibhav
bd-vaibhav force-pushed the OTWO-7704 branch 2 times, most recently from b9b9620 to d197f0a Compare August 5, 2026 10:15
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.

2 participants