Skip to content

fix(frontend): read the org role from the token for shared saved views (#702) - #1500

Merged
alex-dembele merged 1 commit into
developfrom
bug/702-org-role-admin-ui
Nov 21, 2026
Merged

alex-dembele merged 1 commit into
developfrom
bug/702-org-role-admin-ui

Conversation

@alex-dembele

Copy link
Copy Markdown
Member

Closes #702

Owners and admins were shown a member's interface for shared saved views because the gate read the legacy user.role. That field is empty for every sign-up account. The org role of the active organisation now has a single reader, frontend/src/lib/orgRole.ts, built from the token's org_roles[tenant_id]. hasRole, the saved-views gate and the sidebar role label all use it. The risk-weights screen was already fixed by #867; its test now uses the real store, with root, admin and member, instead of a stubbed hasRole.

Verification

  • npx tsc -b --noEmit → exit 0
  • npx eslint and npx prettier --check on the 7 touched files → clean
  • npx vitest run (full) → 1443/1444 passed. The one failure, src/__tests__/App.integration.test.tsx, is a timeout under full-suite load; run alone it passes 2/2 (3/3 tests). Not touched by this diff.
  • The new saved-views tests fail on the old useTableState.ts (3 failed: root, admin, member-with-legacy-admin) and pass with the fix.
  • Live, branch server + Vite on a throwaway Postgres/Redis, sign-up founder (org root, legacy role empty) plus an invited admin and an invited member (business role auditor):
    Account Risk weights (/risks/weighting) Colleague's shared view in the filter panel
    founder, root 8 sliders enabled, Défauts + Enregistrer shown, no read-only notice share toggle + delete shown
    admin 8 sliders enabled, Défauts + Enregistrer shown, no read-only notice share toggle + delete shown
    member (auditor) 8/8 sliders disabled, no buttons, « Lecture seule — rôle administrateur requis pour modifier. » colleague's view: badge only, no toggle or delete; own view still editable
    The server agrees: PUT /risk-scoring/weights 200 for root and admin, 403 for member; PATCH /saved-views/:id of a colleague's view 200 for admin, 403 for member.
  • Token check: a live sign-up token decodes to org_roles with one entry, the active org.

Review

Not done

#702)

Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
@alex-dembele
alex-dembele added this pull request to the merge queue Nov 21, 2026
Merged via the queue into develop with commit 17fdc67 Nov 21, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admins see a member's UI for risk weights and shared saved views — both read the always-empty user.role

1 participant