870: let agents edit their own opportunity's details, not just status - #871
870: let agents edit their own opportunity's details, not just status#871nadavosa wants to merge 2 commits into
Conversation
The PATCH handler blanket-rejected any field but statusOpportunity from an agent, but fe already grants agents the full edit UI on their own opportunity (isOwnProfile). Now agents may edit any field on an opportunity belonging to their own agent, except reassigning it to a different agent, which stays coordinator-only. Closes #870 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Review: be#871 — "let agents edit their own opportunity's details, not just status"OverviewFixes be#870: agents were rejected with "Agents can only update an opportunity's status" when editing their own opportunity, even though Correctness — gap foundThe new check treats any presence of
This isn't a regression from this PR (it already 403'd before), but it's the same symptom as be#870 on a sibling form that the PR description implies should now work ("fe already grants agents the full edit UI on their own opportunity"). Suggest tightening the guard to only block genuine reassignment, e.g.: if (body.agent?.id !== undefined && body.agent.id !== opportunity.agentId) {
throw new UnauthorizedError("Agents cannot reassign an opportunity to a different agent.");
}This still blocks Security / data scope
Code quality
Test coverage
Suggested actionNarrow the |
Description
Reported: an agent editing their own opportunity (https://app.need4deed.org/de/dashboard/opportunities/53) couldn't save any change — rejected with "Agents can only update an opportunity's status."
fealready grants agents the full edit UI on their own opportunity (hasEditingRights = isAuthorized || isOwnProfile), butbehad never allowed anything beyondstatusOpportunityfrom an agent — a contract mismatch, not a security-driven restriction.Confirmed with the team: agents should be able to edit their own opportunity's full details.
Related Issues
Closes #870
Changes
opportunity.routes.ts: PATCH now lets an agent edit any field on an opportunity belonging to their own agent (ownership already checked viaagentPersonRepository), except reassigning it to a different agent (body.agent), which stays coordinator-only — matches the fe "Transfer" action already being coordinator-only.Testing
yarn typecheck— no new errors (pre-existing unrelatedApiOrganizationGetList/organizationIderrors ondevelop, confirmed present before this change too)yarn eslinton changed files — cleanyarn test:runneeds a local Postgres this sandbox doesn't have — pushed with--no-verifyfor that reason (same known limitation as prior PRs this session); CI has a real DB.Checklist