Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2024 06:19:06 PM (22 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/members/test-signup-controller.php

    r14026 r14070  
    5656         */
    5757        public function test_get_items() {
    58                 $this->bp::set_current_user( $this->user );
     58                wp_set_current_user( $this->user );
    5959
    6060                $s1     = $this->create_signup();
     
    7676         */
    7777        public function test_get_paginated_items() {
    78                 $this->bp::set_current_user( $this->user );
     78                wp_set_current_user( $this->user );
    7979
    8080                $s1 = $this->create_signup();
     
    119119                $u = static::factory()->user->create();
    120120
    121                 $this->bp::set_current_user( $u );
     121                wp_set_current_user( $u );
    122122
    123123                $request = new WP_REST_Request( 'GET', $this->endpoint_url );
     
    132132         */
    133133        public function test_get_item() {
    134                 $this->bp::set_current_user( $this->user );
     134                wp_set_current_user( $this->user );
    135135
    136136                $signup = $this->endpoint->get_signup_object( $this->signup_id );
     
    152152         */
    153153        public function test_get_item_with_invalid_signup_id() {
    154                 $this->bp::set_current_user( $this->user );
     154                wp_set_current_user( $this->user );
    155155
    156156                $request = new WP_REST_Request( 'GET', sprintf( $this->endpoint_url . '/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
     
    178178                $u = static::factory()->user->create();
    179179
    180                 $this->bp::set_current_user( $u );
     180                wp_set_current_user( $u );
    181181
    182182                $request = new WP_REST_Request( 'GET', sprintf( $this->endpoint_url . '/%s', $this->signup_id ) );
     
    589589         */
    590590        public function test_delete_item() {
    591                 $this->bp::set_current_user( $this->user );
     591                wp_set_current_user( $this->user );
    592592
    593593                $signup = $this->endpoint->get_signup_object( $this->signup_id );
     
    609609         */
    610610        public function test_delete_item_invalid_signup_id() {
    611                 $this->bp::set_current_user( $this->user );
     611                wp_set_current_user( $this->user );
    612612
    613613                $request = new WP_REST_Request( 'DELETE', sprintf( $this->endpoint_url . '/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
     
    634634        public function test_delete_item_unauthorized_user() {
    635635                $u = static::factory()->user->create();
    636                 $this->bp::set_current_user( $u );
     636                wp_set_current_user( $u );
    637637
    638638                $request = new WP_REST_Request( 'DELETE', sprintf( $this->endpoint_url . '/%d', $this->signup_id ) );
     
    699699
    700700        public function test_prepare_item() {
    701                 $this->bp::set_current_user( $this->user );
     701                wp_set_current_user( $this->user );
    702702
    703703                $signup = $this->endpoint->get_signup_object( $this->signup_id );
Note: See TracChangeset for help on using the changeset viewer.