fix : prevented non-admin users from changing ticket status to closed#793
fix : prevented non-admin users from changing ticket status to closed#793tmdeveloper007 wants to merge 2 commits into
Conversation
|
🎉 Thank you for your contribution! Your pull request has been received and will be reviewed shortly. If you enjoy the project, please consider giving the repository a ⭐. You can also follow my GitHub profile to stay updated on future open-source projects. Thanks for being part of the community! 🚀 |
|
Warning Review limit reached
More reviews will be available in 37 minutes and 35 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo test cases in the ChangesNon-admin ticket status authorization test updates
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/api/src/routes/supportRoutes.js`:
- Around line 252-256: Update the two stale integration tests in
backend/api/test/integration/supportRoutes.test.js to match the new guard logic.
First, in the test at line 313-328 titled "allows owner to change status to
closed", change the expected response status code from 200 to 403 since
non-admins can no longer change ticket status. Second, in the test at line
330-345 titled "denies owner from changing status to in_progress or resolved",
update the expected error message on line 344 from 'Access Denied: Only admins
can change tickets to this status.' to 'Access Denied: Only admins can change
ticket status.' to match the new error message returned by the guard condition
in the supportRoutes.js file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0d622edd-b3e5-4734-8872-ce6d629bb30f
📒 Files selected for processing (1)
backend/api/src/routes/supportRoutes.js
…s-change guard Test 'allows owner to change status to closed' updated to expect 403. Test 'denies owner from changing status to in_progress or resolved' updated to match new error message.
Closes #788.
Summary of What Has Been Done:
Removed the incorrect clause from the status-change guard in PATCH /tickets/:id. The original condition used short-circuit logic that allowed non-admin users to close their own tickets. Now the guard blocks any status change by non-admin users (whether to 'closed' or any other status).
Changes Made:
Impact it Made:
All 239 unit tests pass. Support ticket status changes are now restricted to admins only.
Summary by CodeRabbit