Restrict Remove Friend controls to the signed-in user’s own friend lists #33

Closed
opened 2024-01-14 14:36:32 -06:00 by jimmyb · 1 comment
Owner

Friend action ownership needs to be rebuilt so authenticated users cannot see or use Remove Friend controls while viewing another user's Friends or Friends Of pages.

The original issue reported that a signed-in user could see Remove Friend on a friend list that was not theirs. The rebuilt friending feature now enforces ownership through the user_friends model, authenticated mutation routes, profile-only friend actions, and read-only Friends/Friends Of list pages.

Scope

  • Friends and Friends Of list pages or tabs, where implemented.
  • Remove Friend controls/forms/links.
  • Add Friend controls where they appear beside listed users.
  • Current viewer, profile/list owner, and listed-user relationship state.
  • Server-side authorization for friend mutations.

Acceptance Criteria

  • Authenticated users only see Remove Friend controls for friend relationships they own.
  • Authenticated users do not see Remove Friend controls while browsing another user's Friends or Friends Of list unless the row represents a relationship owned by the current viewer.
  • Users cannot remove another user's friend relationship by submitting crafted requests.
  • Guests never see Add Friend or Remove Friend controls on friend list surfaces.
  • Add Friend controls, where shown, target only valid active users and never the current user.
  • Friend action visibility is consistent between profile action areas, Friends lists, and Friends Of lists.
  • Banned, deleted, soft-deleted, or missing users do not expose friend actions.
  • Friend list rows remain readable even when actions are hidden.
  • User-facing UI supports light/dark mode and follows the existing Laravel/Tailwind site layout patterns.

Test Coverage Required

  • Feature tests confirming Remove Friend is visible only for the signed-in user's own friend relationships.
  • Feature tests confirming Remove Friend is hidden while viewing another user's friend lists.
  • Feature tests confirming forged remove-friend requests cannot remove relationships owned by another user.
  • Feature tests for guest visibility, self-user rows, banned/deleted users, and empty friend list states.
  • Regression tests covering Friends and Friends Of pages/tabs separately.
  • Tests should use Pest and focused feature coverage.
  • Run the focused affected tests, then run vendor/bin/pint --dirty before closing the issue.

Progress Checklist

  • Public profile page exists
  • Profile stats reserve Friends and Friends Of rows
  • Notification settings include friend_added_you
  • Add or confirm friend persistence and ownership model
  • Add Friends and Friends Of list pages or tabs
  • Add server-side authorization for remove-friend actions
  • Show Remove Friend only for relationships owned by the current viewer
  • Hide friend mutation controls when viewing another user's unrelated friend list
  • Handle guests, self-user rows, deleted users, banned users, and empty states
  • Add tests for friend action ownership, forged requests, and list rendering
  • Confirm friend action UI matches expected ownership behavior
Friend action ownership needs to be rebuilt so authenticated users cannot see or use Remove Friend controls while viewing another user's Friends or Friends Of pages. The original issue reported that a signed-in user could see Remove Friend on a friend list that was not theirs. The rebuilt friending feature now enforces ownership through the user_friends model, authenticated mutation routes, profile-only friend actions, and read-only Friends/Friends Of list pages. ## Scope - Friends and Friends Of list pages or tabs, where implemented. - Remove Friend controls/forms/links. - Add Friend controls where they appear beside listed users. - Current viewer, profile/list owner, and listed-user relationship state. - Server-side authorization for friend mutations. ## Acceptance Criteria - Authenticated users only see Remove Friend controls for friend relationships they own. - Authenticated users do not see Remove Friend controls while browsing another user's Friends or Friends Of list unless the row represents a relationship owned by the current viewer. - Users cannot remove another user's friend relationship by submitting crafted requests. - Guests never see Add Friend or Remove Friend controls on friend list surfaces. - Add Friend controls, where shown, target only valid active users and never the current user. - Friend action visibility is consistent between profile action areas, Friends lists, and Friends Of lists. - Banned, deleted, soft-deleted, or missing users do not expose friend actions. - Friend list rows remain readable even when actions are hidden. - User-facing UI supports light/dark mode and follows the existing Laravel/Tailwind site layout patterns. ## Test Coverage Required - Feature tests confirming Remove Friend is visible only for the signed-in user's own friend relationships. - Feature tests confirming Remove Friend is hidden while viewing another user's friend lists. - Feature tests confirming forged remove-friend requests cannot remove relationships owned by another user. - Feature tests for guest visibility, self-user rows, banned/deleted users, and empty friend list states. - Regression tests covering Friends and Friends Of pages/tabs separately. - Tests should use Pest and focused feature coverage. - Run the focused affected tests, then run vendor/bin/pint --dirty before closing the issue. ## Progress Checklist - [x] Public profile page exists - [x] Profile stats reserve Friends and Friends Of rows - [x] Notification settings include friend_added_you - [x] Add or confirm friend persistence and ownership model - [x] Add Friends and Friends Of list pages or tabs - [x] Add server-side authorization for remove-friend actions - [x] Show Remove Friend only for relationships owned by the current viewer - [x] Hide friend mutation controls when viewing another user's unrelated friend list - [x] Handle guests, self-user rows, deleted users, banned users, and empty states - [x] Add tests for friend action ownership, forged requests, and list rendering - [x] Confirm friend action UI matches expected ownership behavior
Codex changed title from Hide ''Remove Friend'' on other users friend lists to Restrict Remove Friend controls to the signed-in user’s own friend lists 2026-05-25 22:22:11 -05:00
jimmyb self-assigned this 2026-06-01 19:48:30 -05:00
Member

Reviewed against the rebuilt friending feature from issue #55 and this is now covered.

Evidence:

  • Friend persistence is modeled in user_friends with directed user_id -> friend_id ownership.
  • POST/DELETE profile friend routes are authenticated.
  • Remove uses the signed-in user's id plus the target friend id, so a crafted request cannot remove another user's relationship.
  • Friends and Friends Of pages are read-only list surfaces and do not render Add/Remove controls for guests or authenticated viewers.
  • Profile Add/Remove controls render only for logged-in non-self viewers, and activePublic filtering prevents banned, deleted, soft-deleted, or missing users from exposing friend actions.

Verification run:

  • php artisan test --compact tests/Feature/UserFriendTest.php tests/Feature/UserProfileTest.php
  • Result: 30 passed, 213 assertions
Reviewed against the rebuilt friending feature from issue #55 and this is now covered. Evidence: - Friend persistence is modeled in user_friends with directed user_id -> friend_id ownership. - POST/DELETE profile friend routes are authenticated. - Remove uses the signed-in user's id plus the target friend id, so a crafted request cannot remove another user's relationship. - Friends and Friends Of pages are read-only list surfaces and do not render Add/Remove controls for guests or authenticated viewers. - Profile Add/Remove controls render only for logged-in non-self viewers, and activePublic filtering prevents banned, deleted, soft-deleted, or missing users from exposing friend actions. Verification run: - php artisan test --compact tests/Feature/UserFriendTest.php tests/Feature/UserProfileTest.php - Result: 30 passed, 213 assertions
Codex closed this issue 2026-06-01 19:52:38 -05:00
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MyVideoGameList/myvideogamelist.com#33
No description provided.