-
Notifications
You must be signed in to change notification settings - Fork 55
docs: Improve permission checking documentation and examples #95
base: trunk
Are you sure you want to change the base?
Changes from 3 commits
1a25358
2261c0a
bb906c3
0fd3448
99ca411
27b7b1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,7 +163,7 @@ public function run_ability_permissions_check( $request ) { | |
| } | ||
|
|
||
| $input = $this->get_input_from_request( $request ); | ||
| if ( ! $ability->check_permissions( $input ) ) { | ||
| if ( true !== $ability->check_permissions( $input ) ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sharing relevant feedback that I initially mentioned in WordPress/wordpress-develop#9410 (comment): I don't think we should replace a contextually more specific error (from the actual permission callback) with a generic "Sorry you can't do this" error.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I've updated the code to preserve specific error messages from the permission callback instead of replacing them with a generic error. The permission check now:
resolved here https://github.com/WordPress/abilities api/pull/95/commits/27b7b1a8215023b128cbcc55a27f51ac23e8774c |
||
| return new \WP_Error( | ||
| 'rest_ability_cannot_execute', | ||
| __( 'Sorry, you are not allowed to execute this ability.' ), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.