Skip to content

Apply the user's throttle helpers to every throttle record - #68

Open
AIC-BV wants to merge 1 commit into
wintercms:mainfrom
AIC-BV:fix/throttle-all-rows
Open

AIC-BV wants to merge 1 commit into
wintercms:mainfrom
AIC-BV:fix/throttle-all-rows

Conversation

@AIC-BV

@AIC-BV AIC-BV commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The throttle keeps one record per user and IP address, but User::isSuspended(), unsuspend(), ban(), unban() and isBanned() only looked at the first record found for the user. For a user who signed in from more than one address:

  • the backend doesn't show the Unsuspend button, and unsuspending doesn't lift the suspension, when the suspended record isn't the first one;
  • ban() only bans the first record, so an existing session on another address stays signed in (Auth::check() reads the record for the current address).

These methods now cover every record of the user. ban() also makes sure a record without an IP address exists, so addresses that have no record yet are banned as well.

tests/unit/models/UserThrottleTest.php covers this; four of its tests fail without the change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Ban and suspension status now account for all of a user’s throttle records, including records across multiple IP addresses.
    • Banning a user also covers cases where no throttle record exists yet for an IP address.
    • Expired suspensions are no longer treated as active, and unbanning or unsuspending clears the status across all records.

The throttle keeps one record per user and IP address, but isSuspended(),
unsuspend(), ban(), unban() and isBanned() only looked at the first record
found for the user. A suspension on another address could not be seen or
lifted from the backend, and a ban left sessions on other addresses alive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

User ban and suspension methods now inspect or update all throttle records for that user. If no record has a null IP address, ban() creates one before applying the ban. New unit tests cover multiple records, expired suspensions, and ban and suspension changes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to e148a

Ban and suspension checks now apply across all of a user's throttle records, and the added unit tests cover this behavior. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title 'Apply the user's throttle helpers to every throttle record' matches the main change. The objectives and summary show that User::ban, unban, isBanned, isSuspended, and unsuspend now cover ev…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title 'Apply the user's throttle helpers to every throttle record' matches the main change. The objectives and summary show that User::ban, unban, isBanned, isSuspended, and unsuspend now cover every throttle record for a user instead of only the first one. The title is specific, is a single sentence, and does not use vague terms. It does not mention the ban() change that creates a record without an IP address, but it does not need to cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

PHPStan (2.3.1)

Composer install failed: dependency resolution error. Check composer.json and composer.lock for version constraints.

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b59eadfb-982a-4201-a759-ce18694cbb5f
Commits

Reviewing files that changed from the base of the PR and between d803332 and e148af8.

Files selected for processing: 2

  • models/User.php
  • tests/unit/models/UserThrottleTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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.

1 participant