Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2024 06:19:06 PM (2 years ago)
Author:
espellcaste
Message:

A user is no longer de-authenticated when making REST API requests.

We are introducing a new BP_LoggedIn_User class to fetch data about a BuddyPress logged-in user. This new addition fixes an issue where a user could be de-authenticated when making REST API requests.

Props dcavins, DJPaul, johnjamesjacoby, and imath.

Closes ​https://github.com/buddypress/buddypress/pull/395
See #9229 and #9145
Fixes #7658

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/test-group-avatar-controller.php

    r14026 r14070  
    4747         */
    4848        public function test_get_item() {
    49                 $this->bp::set_current_user( $this->user );
     49                wp_set_current_user( $this->user );
    5050
    5151                $request = new WP_REST_Request( 'GET', sprintf( $this->endpoint_url . '/%d/avatar', $this->group_id ) );
    … …  
    108108                $reset_post  = $_POST;
    109109
    110                 $this->bp::set_current_user( $this->user );
     110                wp_set_current_user( $this->user );
    111111
    112112                add_filter( 'pre_move_uploaded_file', array( $this, 'copy_file' ), 10, 3 );
    … …  
    178178                $reset_post  = $_POST;
    179179
    180                 $this->bp::set_current_user( $this->user );
     180                wp_set_current_user( $this->user );
    181181
    182182                // Disabling group avatar upload.
    … …  
    208208         */
    209209        public function test_create_item_empty_image() {
    210                 $this->bp::set_current_user( $this->user );
     210                wp_set_current_user( $this->user );
    211211
    212212                $request  = new WP_REST_Request( 'POST', sprintf( $this->endpoint_url . '/%d/avatar', $this->group_id ) );
    … …  
    230230                $u1 = $this->bp::factory()->user->create();
    231231
    232                 $this->bp::set_current_user( $u1 );
     232                wp_set_current_user( $u1 );
    233233
    234234                $request  = new WP_REST_Request( 'POST', sprintf( $this->endpoint_url . '/%d/avatar', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
    … …  
    255255         */
    256256        public function test_delete_item_failed() {
    257                 $this->bp::set_current_user( $this->user );
     257                wp_set_current_user( $this->user );
    258258
    259259                $request  = new WP_REST_Request( 'DELETE', sprintf( $this->endpoint_url . '/%d/avatar', $this->group_id ) );
    … …  
    276276         */
    277277        public function test_delete_item_invalid_group() {
    278                 $this->bp::set_current_user( $this->user );
     278                wp_set_current_user( $this->user );
    279279
    280280                $request  = new WP_REST_Request( 'DELETE', sprintf( $this->endpoint_url . '/%d/avatar', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
Note: See TracChangeset for help on using the changeset viewer.