Skip to content

Instantly share code, notes, and snippets.

@lifeart lifeart/ability.ts
Last active Jan 17, 2020

What would you like to do?
Simple Roles Management
import { get } from '@ember/object';
const permissions = {
study: {
create: ['DATA_ENTRY', 'ADMIN'],
export default {
userRoles: ['ADMIN'],
hasAbility(path: string) {
return (
this.userRoles.filter((role: string) =>
get(permissions, path).includes(role)
).length > 0
// how to use?
// security.hasAbility('study.edit')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.