require_role(role) for functions whose first argument is a user dict with a 'roles' list: the wrapper raises PermissionError unless role is present, else delegates. @require_role('admin') then guards any endpoint-like function.delete_all({'roles': ['admin']})runs normally
The role check passed.
delete_all({'roles': ['viewer']})PermissionError
Missing role blocks the call.
role in user.get('roles', []).
Raise before delegating.