slides: gate management on slides.manage permission (grantable to non-admin curator)
The lobby-display and screensaver slide manager was admin-only. Add a shared slides.manage permission so a curator can manage both surfaces without full admin. Admins keep access via the require_permission admin bypass. Backend: - plugins/slides/api/routes.py: all 5 management routes require slides.manage - plugins/slides/plugin.py: declare it via get_permissions(); nav item carries the permission so the frontend can gate visibility - shopdb/core/api/auth.py: login response now returns the user's permissions (matches /me) so the frontend authStore has them on fresh login Frontend: - stores/auth.js: hasPermission(name) getter (admin true, else granted list) - router/index.js: guard supports requiresPermission - views/AppLayout.vue: hide nav items whose permission the user lacks - plugins/slides/frontend/routes.js: slide manager gated requiresPermission Tests: no-perm user 403, curator role with the perm 200 (+ login advertises it), admin 200 via bypass. Deploy: run `flask seed permissions` to create the row, then grant it to a role in Settings > Users & Roles.
This commit is contained in:
@@ -58,14 +58,25 @@ class SlidesPlugin(BasePlugin):
|
||||
"""Slide playlist metadata (image files live on disk)."""
|
||||
return [TvSlide]
|
||||
|
||||
def get_permissions(self) -> List:
|
||||
"""RBAC permission for curating slides (both surfaces). Grantable to a
|
||||
non-admin role so a curator can manage the lobby TV + screensaver
|
||||
without full admin. Admins hold it by default."""
|
||||
return [
|
||||
('slides.manage',
|
||||
'Manage lobby display and screensaver slides', 'slides'),
|
||||
]
|
||||
|
||||
def get_navigation_items(self) -> List[Dict]:
|
||||
"""Sidebar entry for the slide manager (admin)."""
|
||||
"""Sidebar entry for the slide manager. Gated on slides.manage so only a
|
||||
curator (or admin, who holds it by default) sees the link."""
|
||||
return [
|
||||
{
|
||||
'name': 'Slides',
|
||||
'icon': 'image',
|
||||
'route': '/settings/slides',
|
||||
'position': 7,
|
||||
'permission': 'slides.manage',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user