Skip to content

Instantly share code, notes, and snippets.

@francium-lupe
Last active August 29, 2023 13:58
Show Gist options
  • Save francium-lupe/0143364c0d75418aa6d8385ef6ac7194 to your computer and use it in GitHub Desktop.
Save francium-lupe/0143364c0d75418aa6d8385ef6ac7194 to your computer and use it in GitHub Desktop.
requiredRoles Mapping
if (endpoint && endpoint in requiredRoles) {
if (!roles.find(role => requiredRoles[endpoint].has(role))) {
throw new BadRequest(
`User not authorized for action ${actionName}, has roles "${roles}"`
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment