roles-permissions

Documents polymorphic role and permission gates for the Toollab Laravel and Nuxt application.

Updated May 5, 2025
One-click install
npx skills add https://github.com/sebauvray/toollab-api --skill roles-permissions-sebauvray
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: roles-permissions
Source: https://github.com/sebauvray/toollab-api/tree/main/.claude/skills/roles-permissions
Command: npx skills add https://github.com/sebauvray/toollab-api --skill roles-permissions-sebauvray

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working on the Toollab codebase need to know exactly which role can access which endpoint, how polymorphic school/family/classroom roles work, and how to add new authorization gates without duplicating existing ones or breaking the invitation acceptance flow. ## Core Features & Use Cases - Role model reference: Explains the six roles (director, admin, registar, teacher, responsible, student), their polymorphic contexts, and the slug-vs-French-name filtering rule. - Gate catalog: Maps every backend gate (CheckRole middleware, canManageUser, callerCanAccessFamily, StaffRolePermissions) with guidance on which to reuse instead of creating new ones. - Invitation and acceptance flow: Documents the accepted_at membership mechanism, super-admin derivation from environment config, and the single active role logic on the Nuxt front end. - Use Case: When adding a new payment mutation endpoint, consult this Skill to decide whether the registar role should pass, which middleware to apply, and how to hide the UI for unauthorized roles. ## Quick Start Ask the assistant which roles should be allowed to modify family payment lines and which existing gate covers that case.

Frequently Asked Questions about roles-permissions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new authorization gate in a Laravel app with polymorphic roles?▼

First check whether an existing gate covers the need, such as CheckRole middleware, callerCanAccessFamily, or StaffRolePermissions. If a new gate is required, filter roles by slug, add whereNotNull('accepted_at') for school-context roles, and return a generic refusal message with a logged warning.

How do polymorphic user roles work across schools, families, and classrooms?▼

A user_roles table stores role_id, user_id, and a polymorphic roleable context of school, family, or classroom. One user can hold multiple roles simultaneously in different contexts, such as admin of one school and responsible of a family.

Should I filter roles by slug or by display name in Laravel queries?▼

Always filter by slug in backend queries using whereHas on the role relation. French display names are only for UI labels, so renaming a role's name breaks nothing while changing a slug requires updates across seeders, middleware, and front-end utilities.

Why is a staff member invisible to a school after being invited?▼

The membership invitation has not been accepted yet, so accepted_at is null and the school only sees the email with a pending badge. The user must accept via the set-password link or the in-app invitation banner before their name becomes visible.

How does the front end handle users with multiple roles in Nuxt?▼

The front end stores all role slugs in localStorage but computes every permission from a single active role chosen in the account menu. Use hasAnyRole with readActiveSchoolRoles from the schoolRoles utility module rather than the legacy singular key.

How is super admin status determined without a database flag?▼

The is_super_admin attribute is derived by checking whether the user's email appears in the SUPER_ADMIN_EMAILS environment variable loaded through config. In production the config is cached, so changes require a config:cache run or container restart to take effect.