One or more roles that are permitted to access the route
Express middleware function
// Only owners and managers can add employees
router.post('/:workspaceId/employees',
requireAuth,
requireRole('OWNER', 'MANAGER'),
addEmployeeHandler
)
// Any workspace member can view the schedule
router.get('/:workspaceId/schedule',
requireAuth,
requireRole('OWNER', 'MANAGER', 'EMPLOYEE'),
getScheduleHandler
)
Authorisation middleware factory — Layer 2 of 2.
Returns a middleware that verifies the authenticated user is a member of the workspace in
:workspaceIdwith one of the specified roles. Attaches the fullMembership(includingworkspace) toreq.membership.Must be used after
requireAuthsince it relies onreq.user.Calls
next(Forbidden(...))if:roleslist