diff --git a/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md b/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md index 7ee14a98..19f541ef 100644 --- a/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md +++ b/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md @@ -72,9 +72,12 @@ the equine working copy content work (V1-2.8), any DEV operation (§16.11), reco - Skips: `apps/app/e2e/shell/admin.spec.ts` skips A0, A1 and S1 on the `chromium-375` project only (three `test.skip(isPhone(info))`). These journeys run on desktop; every admin page at 375 px is covered by the unskipped screens test and the access-per-right test. Deliberate, not a reduction. -- C4 gap fixed: `/app/admin/sheets/new` shows « Accès non autorisé » to any account without an active - `sheet_editor` grant (display rule; the server refuses creation anyway); unit tests for a reviewer, a - publisher and an owner without the capability. +- C4 gap fixed: `/app/admin/sheets/new` shows « Accès non autorisé » to any account whose own grants, once + read, hold no active `sheet_editor` grant (display rule; the server refuses creation anyway); unit tests for + a reviewer, a publisher and an owner without the capability. While the grants load the page waits; when + their read failed (or the account itself could not be read) it shows the form and the server decides, + rather than denying an editor for good: a reviewer may then see the form and be refused on submit. + Submitted for the owner's acknowledgement at the checkpoint. - Security MEDIUM fixed: M7 restates the grants of the redefined `get_sheet_version`. LOW fixed: the e2e enrolment check no longer prints the throwaway setup key on failure. - Run evidence for the criteria a read-only verifier cannot run (orchestrator runs, sandbox only): diff --git a/apps/app/src/state/authStore.ts b/apps/app/src/state/authStore.ts index cbc21a43..555db48b 100644 --- a/apps/app/src/state/authStore.ts +++ b/apps/app/src/state/authStore.ts @@ -210,6 +210,8 @@ function applyAuthEvent( profile: null, roles: [], workspace: { status: 'error', failure: classifyRecordError(error) }, + // The grant read never ran: no page waits on it forever. + catalogGrantsStatus: 'failed', }) }) }, 0) diff --git a/apps/app/tests/unit/state.authStore.test.ts b/apps/app/tests/unit/state.authStore.test.ts index 455abfe1..81bc25aa 100644 --- a/apps/app/tests/unit/state.authStore.test.ts +++ b/apps/app/tests/unit/state.authStore.test.ts @@ -105,13 +105,16 @@ describe('authStore', () => { await flush() await flush() expect(useAuthStore.getState().catalogGrants).toEqual([grant]) + expect(useAuthStore.getState().catalogGrantsStatus).toBe('ready') fake.emit('SIGNED_IN', fakeSession(fakeUser({ id: 'user-2' }))) expect(useAuthStore.getState().catalogGrants).toEqual([]) + expect(useAuthStore.getState().catalogGrantsStatus).toBe('loading') await flush() await flush() expect(useAuthStore.getState().catalogGrants).toEqual([]) fake.emit('SIGNED_OUT', null) expect(useAuthStore.getState().catalogGrants).toEqual([]) + expect(useAuthStore.getState().catalogGrantsStatus).toBe('loading') }) it('updateProfile writes the row and keeps the store in sync', async () => { @@ -220,6 +223,25 @@ describe('authStore', () => { }) }) + it('marks the own grants failed when the account itself cannot be read', async () => { + const from = fake.client.from.bind(fake.client) + // Any chain on profile_roles answers an error, as a dropped request would. + const failed: unknown = new Proxy(() => undefined, { + get: (_, key) => + key === 'then' + ? (resolve: (v: unknown) => void) => + resolve({ data: null, error: { code: '', message: 'FetchError' }, status: 0 }) + : () => failed, + }) + ;(fake.client as unknown as { from: (t: string) => unknown }).from = (table: string) => + table === 'profile_roles' ? failed : from(table as never) + stop = useAuthStore.getState().start() + fake.emit('SIGNED_IN', fakeSession()) + await flush() + await flush() + expect(useAuthStore.getState().catalogGrantsStatus).toBe('failed') + }) + it('reports a failed read as an error kind and reads again on refresh', async () => { const from = fake.client.from.bind(fake.client) let failing = true