Skip to content

Hide locked users' profiles from the non-admin people index#1489

Merged
maebeale merged 1 commit into
mainfrom
maebeale/locked-user-search
May 15, 2026
Merged

Hide locked users' profiles from the non-admin people index#1489
maebeale merged 1 commit into
mainfrom
maebeale/locked-user-search

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Apr 17, 2026

What is the goal of this PR and why is this important?

  • Once non-admin users can see the People index (see HOLD UNTIL READY TO LAUNCH: Allow authenticated users to access the people index and search #1494), they will not see profiles whose user is locked
  • Locked accounts have had access revoked; their profile should not be discoverable by facilitators on people index
  • Admins are unaffected — they continue to see all people, locked or not
  • NOTE: this code doesn't do anything rn bc facilitators don't have the People index permission yet, but, adding this logic now before we forget this additional condition

How did you approach the change?

  • Added a Person.where_user_not_locked scope: left_joins(:user) so people with no user record are still included, then keeps only rows where users.locked_at IS NULL
  • Chained .where_user_not_locked onto the non-admin branch of PersonPolicy's relation_scope, after the existing searchable.with_active_affiliations filters
  • Updated the policy spec to assert the generated SQL also includes users.locked_at IS NULL

UI Testing Checklist

  • Sign in as a regular user. Lock a user account that has a Person with an active affiliation and profile_is_searchable: true. Confirm that profile no longer appears on /people
  • Confirm a Person with no associated user but an active affiliation still appears for regular users
  • Confirm an admin viewing /people still sees locked users' profiles

Anything else to add?

@jmilljr24
Copy link
Copy Markdown
Collaborator

I wrote up this issue before seeing your PR. #1490

@maebeale maebeale force-pushed the maebeale/locked-user-search branch from 5842ef5 to 29614f7 Compare May 15, 2026 13:43
@maebeale maebeale changed the title Allow regular users to search the people index Hide locked users' profiles from the non-admin people index May 15, 2026
@maebeale maebeale changed the base branch from main to maebeale/people-index-authenticated May 15, 2026 13:44
@maebeale maebeale force-pushed the maebeale/locked-user-search branch from 29614f7 to 4a9212b Compare May 15, 2026 14:16
@maebeale maebeale force-pushed the maebeale/people-index-authenticated branch from 42ab70f to 9dbb9c9 Compare May 15, 2026 14:16
@maebeale maebeale changed the base branch from maebeale/people-index-authenticated to main May 15, 2026 14:30
Add a where_user_not_locked Person scope and chain it onto the
non-admin relation_scope so that profiles whose user account is
locked are excluded. People with no user record are still included.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@maebeale maebeale force-pushed the maebeale/locked-user-search branch from 4a9212b to a4bb4e2 Compare May 15, 2026 14:31
@maebeale maebeale marked this pull request as ready for review May 15, 2026 14:32
@maebeale maebeale merged commit 4c2fc0c into main May 15, 2026
3 checks passed
@maebeale maebeale deleted the maebeale/locked-user-search branch May 15, 2026 14:39
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