Skip to content

Invoice Access Control and Role-Gating UI #512

Description

@Kingsman-99

Description

All authenticated users who navigate to an invoice detail URL can see and interact with action buttons regardless of whether they are the creator, a recipient, or an unrelated party. Role-based UI gating must ensure only authorized parties see the correct actions and data.

Technical Context

src/app/invoice/[id]/page.tsx fetches the invoice and compares invoice.creatorPublicKey and invoice.recipients[].publicKey against the connected wallet's public key from src/context/WalletContext.tsx. A src/hooks/useInvoiceRole.ts (new) hook returns 'creator' | 'recipient' | 'viewer'. Action buttons, edit links, and sensitive financial breakdowns are conditionally rendered based on the role. Unauthorized direct API calls are blocked server-side in src/app/api/invoices/[id]/route.ts.

Acceptance Criteria

  • Users identified as creator see edit, clone, cancel, and release actions
  • Users identified as recipient see their own payment status and a "Pay my share" action
  • Users identified as viewer see only publicly available invoice metadata with no action buttons
  • Role determination is derived from the on-chain state and wallet public key, not from a client-settable flag
  • Server routes return 403 for any action a non-creator or non-recipient attempts via direct API call
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions