Fix people index for non-admin access (#1490)#1496
Draft
maebeale wants to merge 1 commit into
Draft
Conversation
Prepares the people index to be safe when exposed to non-admins: qualifies the ambiguous `end_date` in `Affiliation.active`, hides people whose user account is locked from the non-admin scope, and gates the index's person/organization links by their show policy so they degrade gracefully when the viewer lacks access. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
402d15f to
733b31e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1490
What is the goal of this PR and why is this important?
Personprofile to non-admins, harden the/peopleindex so it doesn't crash on a search filter and renders only links the viewer can follow.How did you approach the change?
end_date: qualified the column insideAffiliation.active(affiliations.end_date) so merging it onto a relation that also joinsorganizations(which has its ownend_date) no longer raisesTrilogy::ProtocolError: 1052: Column 'end_date' in where clause is ambiguous. Added regression tests that join:organizationand that chainPerson.with_active_affiliations.search_by_params(organization_name: ...).app/views/people/people_results.html.erb: gated the person profile button, organization affiliation pills, and the overflow+Nlink withallowed_to?(:show?, ...). When the viewer lacks access, the same content renders as plain text instead of a link. Expanded the fragment-cache key to include whether the viewer owns the row so policy-gated output stays correct.UI Testing Checklist
/peoplerenders with all existing links (person profile, organization pills, edit, user)organization_nameno longer 500s (regression check for the ambiguous column)OrganizationPolicy#show?returns falseAnything else to add?
PersonPolicy#index?(admin-only onmain), so the view changes are dormant until the policy opens up. The third issue checklist item ("check policies for all links in the index results") is addressed defensively rather than waiting for the policy change.🤖 Generated with Claude Code