Files
romm/frontend
zurdiandClaude Opus 4.7 eba4539909 feat(frontend-v2): permission system (useCan, permissionsStore, role-map)
Centralised permission checks for v2 — closes the constitution's
"never inline-check user.role in features" rule. Three pieces:

- src/stores/permissions.ts: Pinia store holding the user's
  effective grants. Today populated by hydrateFromRole() against a
  role-map; tomorrow populated by setGrants() from /permissions/me.
  Lives in the canonical store directory but is v2-only consumed —
  v1 keeps its inline checks until removal.

- src/v2/composables/useCan: ActionKey vocabulary, scope vocabulary
  ({global,platform,collection,rom}), role-map mirroring backend
  guards, and useCan(action, scope?) returning ComputedRef<boolean>.
  installPermissionsHydration() watches authStore.user and keeps
  the store in sync; AppLayout calls it on mount.

- Migrations: UserMenu.vue's isAdmin computed and SettingsNav's
  Server Stats visibility gate now go through useCan("app.admin").
  No more `user.role === "admin"` inline checks in v2.

Backend debt remains: ActionKey enum in OpenAPI + /permissions/me
endpoint + permissions:changed socket event. Until those land, the
role-map.ts file must be reviewed against backend role guards by
hand. Drift means the UI will offer actions the server rejects, or
hide actions it would have permitted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 14:28:14 +00:00
..
2026-04-05 17:57:48 -04:00
2026-03-31 08:19:06 -04:00
2026-02-16 22:11:47 -05:00
2025-09-09 20:19:30 -04:00
2024-05-21 10:18:13 -04:00