Skip to content

Read page data through operations, not database tables #700

Open

Description

@alukach

Depends on #694 for the account and product pages.

Problem

API.md says that a page reads the records it renders through an operation in src/lib/operations/. Many pages do not do this. They read the database tables directly. Some pages then call isAuthorized themselves, and some do not check permissions at all.

Thus, the web app and the API can disagree about a rule. For example, the API hides a disabled account, but source.coop/portolan shows the disabled portolan account to all users.

Proposal

Change each page in the list below to read its records through an operation. Remove the isAuthorized calls that the operation already does. If no operation exists for a read, add one, and add its /api/v1 route.

Pages

These files read accountsTable, productsTable, membershipsTable, or dataConnectionsTable directly.

Public pages (do these first):

Account settings:

  • src/app/(app)/edit/account/[account_id]/layout.tsx
  • src/app/(app)/edit/account/[account_id]/profile/page.tsx
  • src/app/(app)/edit/account/[account_id]/profile-picture/page.tsx
  • src/app/(app)/edit/account/[account_id]/permissions/page.tsx
  • src/app/(app)/edit/account/[account_id]/memberships/page.tsx
  • src/app/(app)/edit/account/[account_id]/service-accounts/page.tsx
  • src/app/(app)/edit/account/[account_id]/service-accounts/[service_account_id]/page.tsx
  • src/app/(app)/edit/account/[account_id]/service-accounts/create/page.tsx
  • src/app/(app)/edit/account/[account_id]/data-connections/[data_connection_id]/page.tsx
  • src/app/(app)/edit/account/[account_id]/data-connections/create/page.tsx

Product settings:

  • src/app/(app)/products/new/page.tsx
  • src/app/(app)/edit/product/[account_id]/[product_id]/layout.tsx
  • src/app/(app)/edit/product/[account_id]/[product_id]/details/page.tsx
  • src/app/(app)/edit/product/[account_id]/[product_id]/memberships/page.tsx
  • src/app/(app)/edit/product/[account_id]/[product_id]/data-connections/page.tsx

Admin tools:

  • src/app/(app)/admin/data-connections/page.tsx
  • src/app/(app)/admin/data-connections/[data_connection_id]/page.tsx

Acceptance criteria

  • No file under src/app/(app)/ imports a table client from @/lib/clients/database to read records.
  • Each changed page shows the same records to each role as the API does. A page test or an operation test covers each role.
  • We can do this in more than one PR. Each PR changes one group of pages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions