Created
July 26, 2017 12:03
-
-
Save stalniy/d95585182bcb652cfa4b58e947637dbf to your computer and use it in GitHub Desktop.
CASL blog app abilities ES6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AbilityBuilder } from 'casl' | |
const user = whateverLogicToGetUser() | |
const ability = AbilityBuidler.define(can => { | |
can('read', ['Post', 'Comment']) | |
if (user.isLoggedIn) { | |
can('create', 'Post') | |
can('manage', ['Post', 'Comment'], { authorId: user.id }) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment