accesscontrol icon indicating copy to clipboard operation
accesscontrol copied to clipboard

Rules support?

Open ptheofan opened this issue 3 years ago • 1 comments

The project looks great but going through the documentation I could not find anything with regard to rules. If you wanted to do the typical following use case, how would you go about it with accesscontrol?

Author -> updateArticle::(only articles owned by author)

ptheofan avatar Jun 21 '21 09:06 ptheofan

@ptheofan I think it's in the documentation and is the very common use case. You could do the following:

ac.can(role).updateOwn('article')

article is the resource. Before this role, you have to make sure that the article in question is actually owned by that user. That "check" is not part of this library and that's something the application should do beforehand. It's in FAQs.

https://onury.io/accesscontrol/?content=faq#can-i-use-accesscontroljs-with-a-database--how-

Hope that helps.

hamxabaig avatar Nov 11 '21 07:11 hamxabaig