Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give permission for user to edit a post with specified id #14

Closed
xenDE opened this issue Aug 27, 2018 · 1 comment
Closed

give permission for user to edit a post with specified id #14

xenDE opened this issue Aug 27, 2018 · 1 comment

Comments

@xenDE
Copy link

xenDE commented Aug 27, 2018

hi,

it's possible to give a user an edit permsion to one post/something?

is this possible with "spatie/laravel-permission", i dont see examples for this there?

best regards,
daniel

@drbyte
Copy link
Contributor

drbyte commented Aug 28, 2018

spatie/laravel-permission doesn't store details about individual records. It provides authorization infrastructure at the model level.

To control at the record level in a given model you can do that inside your app. Possible ways in your app include making your model have flags for things like a record-type or a record-status, and then set a Policy which enforces authorization based on that flag (possibly in conjunction with a Permission). Or if you're trying to control author-only access to a Post or something, then track the author_id and use a Policy to ensure that only author_id which matches auth()->id() can do certain actions.
A recent Medium article covers some of these concepts if you're looking for more reading on the topic: https://m.serversideup.net/laravel-gates-and-policies-in-an-api-driven-spa-dbe172d13518 There are lots more articles on Authorization concepts on Medium as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants