diff --git a/lib/api/WP_Auth0_Api_Change_Email.php b/lib/api/WP_Auth0_Api_Change_Email.php index 256dac16..2341cfc2 100644 --- a/lib/api/WP_Auth0_Api_Change_Email.php +++ b/lib/api/WP_Auth0_Api_Change_Email.php @@ -66,6 +66,7 @@ public function call( $user_id = null, $email = null ) { ->add_body( 'email', $email ) // Email is either changed by an admin or verified by WP. ->add_body( 'email_verified', true ) + ->add_body( 'client_id', $this->options->get( 'client_id' ) ) ->patch() ->handle_response( __METHOD__ ); } diff --git a/tests/testApiChangeEmail.php b/tests/testApiChangeEmail.php index e1e9a95b..34bddc8d 100644 --- a/tests/testApiChangeEmail.php +++ b/tests/testApiChangeEmail.php @@ -68,6 +68,7 @@ public function testThatFailedApiReturnsFalse() { public function testThatApiCallIsFormedCorrectly() { $this->startHttpHalting(); self::$opts->set( 'domain', self::TEST_DOMAIN ); + self::$opts->set( 'client_id', '__test_client_id__' ); // Should succeed with a user_id + provider and set_bearer returning true. $change_email = $this->getStub( true ); @@ -86,7 +87,10 @@ public function testThatApiCallIsFormedCorrectly() { $this->assertEquals( 'PATCH', $decoded_res['method'] ); $this->assertArrayHasKey( 'email', $decoded_res['body'] ); $this->assertEquals( 'email@address.com', $decoded_res['body']['email'] ); + $this->assertArrayHasKey( 'email_verified', $decoded_res['body'] ); $this->assertTrue( $decoded_res['body']['email_verified'] ); + $this->assertArrayHasKey( 'client_id', $decoded_res['body'] ); + $this->assertEquals( '__test_client_id__', $decoded_res['body']['client_id'] ); } /**