mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 00:01:27 +01:00
REST API: Return the proper status code for failed permission callbacks in WP_REST_Server->dispatch()
.
Use the `rest_authorization_required_code()` function to return a 401 status code when a permission callback fails due to a user not being logged in. Props jaswrks. Fixes #42828. Built from https://develop.svn.wordpress.org/trunk@42421 git-svn-id: http://core.svn.wordpress.org/trunk@42252 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
386a5c397f
commit
a787006298
@ -915,7 +915,7 @@ class WP_REST_Server {
|
||||
if ( is_wp_error( $permission ) ) {
|
||||
$response = $permission;
|
||||
} elseif ( false === $permission || null === $permission ) {
|
||||
$response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) );
|
||||
$response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42420';
|
||||
$wp_version = '5.0-alpha-42421';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user