Skip to content

Commit

Permalink
Remove excessive REST authentication call.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymitr committed Oct 30, 2024
1 parent 9b3202f commit 2e1ae27
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions projects/plugins/jetpack/class.json-api-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -2722,18 +2722,14 @@ final public function rest_permission_callback() {
return new WP_Error( 'site_not_connected' );
}

$user_id = Rest_Authentication::init()->wp_rest_authenticate( false );

$user_id = get_current_user_id();
$allow_blog_token = $this->allow_fallback_to_jetpack_blog_token || $this->allow_jetpack_site_auth;

if ( ( $allow_blog_token && Rest_Authentication::is_signed_with_blog_token() ) || ( $user_id && Rest_Authentication::is_signed_with_user_token() ) ) {
$custom_permission_result = $this->rest_permission_callback_custom();

// Successful custom permission check.
if ( $custom_permission_result === true ) {
if ( $user_id ) {
wp_set_current_user( $user_id );
}
return true;
}

Expand Down

0 comments on commit 2e1ae27

Please sign in to comment.