Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Authorization checks compared a User object with a string, causing type mismatch that always evaluates true, bypassing access control.

Changes

  • Updated authorization logic in edit(), update(), and delete() methods to compare integer IDs instead of object-to-string comparison

Before:

if( !$user->isAdmin() && !$user->isEditor() && $post->getAuthor() !== $user->getUsername() )

After:

if( !$user->isAdmin() && !$user->isEditor() && $post->getAuthorId() !== $user->getId() )

This ensures non-admin/non-editor users can only modify posts they authored.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: ljonesfl <1099983+ljonesfl@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on service architecture PR Fix authorization type mismatch in PostController Nov 11, 2025
Copilot AI requested a review from ljonesfl November 11, 2025 03:15
Copilot finished work on behalf of ljonesfl November 11, 2025 03:15
@ljonesfl ljonesfl marked this pull request as ready for review November 11, 2025 03:20
@ljonesfl ljonesfl merged commit b5cd6cb into feature/service-architecture Nov 11, 2025
2 checks passed
@ljonesfl ljonesfl deleted the copilot/sub-pr-6-again branch November 11, 2025 03:25
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