-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Core Data selector canUser does not handle entity records #43751
Comments
Thanks for creating the issue. I think we might want to keep The |
I think most custom entities would be using a non
I like that a lot too. |
@Mamaduka we can't rename it, as it is a part of the public API, but we can create a new one and deprecate the old one. How about |
@adamziel, right. We should deprecate the |
I just want to cross-link the "Short-circuit HEAD methods in Core controllers" core ticket. When it's available in core, I think it would be a nice addition to the new selector/resolver. |
Description
The
@wordpress/core-data
module provides a selectorcanUser( action, resource, id )
that can interrogate whether a user has permission to perform the given CRUD action for the given resource and optionally a specific record.For example, to check whether the user can update a
page
with the id of5
, you can perform the following check.Unfortuantely, this method only supports resources that are in the
wp/v2
namespace. Additionally, it requires you to know the final REST API path. Typically, however, only an entitykind
andname
are known.There currently exists a
canUserEntityRecord
selector, but it is only a wrapper forcanUser
and does not Post Type entity records. Additionally, it only supports Post Types that have thewp/v2
namespace which is not a requirement since WP 5.9.gutenberg/packages/core-data/src/selectors.ts
Lines 996 to 1009 in 1d778aa
I think
canUserEntityRecord
should be adapted to actually perform the permission handling logic utilizing thebaseURL
property of the entity config. ThencanUser
would be deprecated.Step-by-step reproduction instructions
canUser
selector via the browser console.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: