Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2024 06:19:06 PM (5 months 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/functions.php

    r13980 r14070  
    6161
    6262        // Set the current user so the leave group request goes through.
    63         self::set_current_user( $u2 );
     63        wp_set_current_user( $u2 );
    6464        groups_leave_group( $g1, $u2 );
    6565        $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
     
    7979
    8080        // Fool the admin check
    81         self::set_current_user( $u1 );
     81        wp_set_current_user( $u1 );
    8282        buddypress()->is_item_admin = true;
    8383
     
    100100
    101101        // Fool the admin check
    102         self::set_current_user( $u1 );
     102        wp_set_current_user( $u1 );
    103103        buddypress()->is_item_admin = true;
    104104
     
    140140
    141141        $current_user = bp_loggedin_user_id();
    142         self::set_current_user( $u2 );
     142        wp_set_current_user( $u2 );
    143143
    144144        $g = self::factory()->group->create( array( 'status' => 'private' ) );
     
    152152        $this->assertEquals( 1, bp_get_user_meta( $u1, 'total_group_count', true ) );
    153153
    154         self::set_current_user( $current_user );
     154        wp_set_current_user( $current_user );
    155155    }
    156156
     
    168168
    169169        // Fool the admin check
    170         self::set_current_user( $u1 );
     170        wp_set_current_user( $u1 );
    171171        buddypress()->is_item_admin = true;
    172172
     
    227227
    228228        // Fool the admin check
    229         self::set_current_user( $u1 );
     229        wp_set_current_user( $u1 );
    230230        buddypress()->is_item_admin = true;
    231231
     
    248248
    249249        // Fool the admin check
    250         self::set_current_user( $u1 );
     250        wp_set_current_user( $u1 );
    251251        buddypress()->is_item_admin = true;
    252252
     
    311311
    312312        // Fool the admin check
    313         self::set_current_user( $u1 );
     313        wp_set_current_user( $u1 );
    314314        buddypress()->is_item_admin = true;
    315315
     
    382382        ) );
    383383
    384         self::set_current_user( $u1 );
     384        wp_set_current_user( $u1 );
    385385        $g1 = self::factory()->group->create();
    386386
     
    389389        $this->assertEquals( 2, groups_get_total_member_count( $g1 ) );
    390390
    391         self::set_current_user( $current_user );
     391        wp_set_current_user( $current_user );
    392392    }
    393393
Note: See TracChangeset for help on using the changeset viewer.