Really hard to grasp the concepts as a newbie
See original GitHub issueHi there! I really want to use CASL for my app, i’ve read the docs and examples multiple times, but i pretty much have no idea how to use it exactly.
What i don’t get especially is: What exactly are things like ‘read’ and ‘all’ ? where/how are they defined? how can i define them myself?
if i want to give users the ability to delete a post and display a button if they can… like can('delete', 'post')
how does CASL know what ‘delete’, ‘post’ and ‘button’ are? it has to be defined somewhere, but i haven’t found out where. probably it’s related to db-query verbs, but then again there are cases where it can’t be just translated to CRUD, right? it seems to “just work” in all the examples i have seen. so basically i have no idea how to translate that to my app, where i have to customize that.
is there a beginner-friendly explanation somewhere that i have overlooked? something that covers the absolute basics? sorry if this seems stupid, i just can’t get my head around it it seems 😕
regards 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:13 (8 by maintainers)
Top GitHub Comments
Hi there and thanks very much for your reply 😃 it’s nice to have that kind of support 😃
My stack is pretty basic: Vue 2.5.16, vuex 2.4.0, vuetify 1.2.5, for now i’m working with a mock backend that’s supposed to return an array of roles for the user like roles: [‘admin’, ‘mod’]. my problem is: how can i translate those roles to abilities? how exactly do i define anything? I want to merge the abilities of the provided roles, which is (as far as i understood) the way it is supposed to work with CASL. I’ve set up an ability.js with const admin etc., but now i’m stuck at “how does CASL know what i mean when i define 'can(‘edit’, ‘chatMessage’) or similar”
like i said, all the articles and docs seem to be assuming that part is already understood by everyone 😄 but i’m having a hard time. i’ve read most of the articles and examples you mentioned, but they didn’t help very much. all i ever see is “easy, just install casl, write a bunch of can(‘this’, ‘that’), and everything works!”. But i’m pretty sure that’s not how it works 😄 I thought there might be a youtube video visualizing the concepts, but there seems to be none as well.
so i’ll probably just need a more abstract visualization of how everything is connected, how and where things are defined and how it plays together.
thanks again very much 😃
You need to update your existing ability instance by rules from each role. The example in docs is more for backend but you can check example for vue integration with vuex and api: https://github.com/stalniy/casl-vue-api-example
Thanks for the issue, I close this and will plan an update in docs (#144)