Repository navigation
fix: SCO-213 refuse guests and let brand sales create returns - #401
Merged
Merged
Conversation
Guests could open return requests (the rep INSERT policy checked membership only) and add lines to any request they could read. Guests now see returns but cannot create them, at every layer: the create action, the /returns/new load, the New return button, the order menu item, and RLS on both return_authorizations and return_lines. Brand-org sales may now create returns, opened as requested for an admin, owner or member to approve. SCO-213 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Summary
mayCreateReturn()increate-return.ts: admin, owner, member and sales may create a return on either side; buyers stay pinned to their own account; guests are refused.initialReturnStatus()now takes the actor's role. Only an admin, owner or member of the issuing org creates a return alreadyapproved. Brand-org sales (BLSR) open it asrequestedfor an approver./returns/newload (403) and action, the "New return" button on/returns, andresolveReturnEntry()(order menu item). The menu label follows the status the row would start at.20261030000001_returns_request_role_gate.sql:return_authorizationsnow requires admin/owner/member/sales (it checked membership only).requested.return_linesINSERT names its initiators explicitly. Before, any guest who could read an open request could add lines to it./returns/newrow).Why
A guest in a rep org could log a return, and the order menu offered "Request return" to guests on delivered orders. Roles & Access makes guest read-only. Brand sales should be able to create returns but not approve them.
Verification
bun run lintpassesbun run checkpasses (0 errors)bun run test:runpasses (2101)bun run test:rlspasses (522), with new cases for rep guest, brand guest, rep sales, and brand sales (requested allowed, approved refused, lines). The three guest cases were confirmed to fail against the old policies.pg_policiesTest plan
/returnsshows the list without "New return";/returns/newreturns 403; a delivered order has no return item in its menu.Closes SCO-213
🤖 Generated with Claude Code