fix(auth): source the user role from mokosh-server /api/v1/auth/me (PMS-158) #100
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/mapps-158-role-from-server-me"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Fix the signed-in user's role always displaying as technician (PMS-158) by sourcing the role from mokosh-server's authoritative
GET /api/v1/auth/me.Root cause
The role was read from the OIDC id_token, but that claim cannot carry the mokosh role: bunyip mints its own
bunyip_role(subscriber/admin) and the mapping to a mokosh role (admin -> super_admin, etc.) is applied server-side (PMS-172). So the id_token claim the SPA parsed was absent and every user fell back to theTechniciandefault. The code that would have corrected it fetched/v1/auth/mefrom the issuer (bunyip), which 404s (observed in dev logs).Changes
refresh_user_from_menow fetchesGET /api/v1/auth/mevia the API client (the mokosh-server endpoint that returns the already-translated role), dropping the unusedOidcConfigargument.Technician.use_current_user_loader, mounted at the app root, so the authoritative user is fetched once on first authenticated mount. Previously the merge only ran inside the token-refresh loop, so the corrected role would not appear until the first refresh window; now it is correct right after login and on rehydrate.Unblocks
MAPPS-133: a technician fails
can_view_financials, so once the role is correct an admin / manager can open the billing pages.Dependencies
bunyip emitting
bunyip_role- access token: BUNYIP-66 (already merged); id token: companion bunyip PR psa-systems/bunyip#86. mokosh-server needs no change (PMS-172 already readsbunyip_role).Verification
cargo check --target wasm32-unknown-unknownandcargo fmt --checkclean. (The one host clippy hit isclippy::manual_checked_opson pre-existingprojects.rs:685, a lint that only exists in host rust 1.95; CI runs rust 1.94 where it does not fire.)🤖 Generated with Claude Code