Can manage own? #149
-
Potentially dumb question: Is there a way to allow users to manage their own documents, but not others? So you could say can("read:own", "Note"), and then blitz-guard would check* that * It's not obvious how blitz-guard could do this, as it would have to be able to access the note object. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey you are right. It's not clear at all, The guard receives the same args as the query/mutation. So you can do: or something along these lines. If you want to improve the documentation (and earn a hacktoberfest contribution) I'll check it and merge it. :) |
Beta Was this translation helpful? Give feedback.
Hey you are right. It's not clear at all,
The guard receives the same args as the query/mutation.
https://ntgussoni.github.io/blitz-guard/docs/ability-file#can--cannot
So you can do:
can("read:own", "note", (args: TypeFromQueryOrMutation) => args.note.userId == ctx.user.id )
or something along these lines.
If you want to improve the documentation (and earn a hacktoberfest contribution) I'll check it and merge it. :)