Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions 16 lib/endpoints/class-wp-rest-users-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public function register_routes() {
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'create_item' ),
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
'password' => array(
'required' => true,
),
) ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
Expand All @@ -46,9 +42,7 @@ public function register_routes() {
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_item' ),
'permission_callback' => array( $this, 'update_item_permissions_check' ),
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), array(
'password' => array(),
) ),
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
array(
'methods' => WP_REST_Server::DELETABLE,
Expand Down Expand Up @@ -747,6 +741,12 @@ public function get_item_schema() {
'type' => 'array',
'context' => array( 'edit' ),
),
'password' => array(
'description' => __( 'Password for the resource (never included).' ),
'type' => 'string',
'context' => array(), // Password is never displayed
'required' => true,
),
'capabilities' => array(
'description' => __( 'All capabilities assigned to the resource.' ),
'type' => 'object',
Expand Down
5 changes: 4 additions & 1 deletion 5 tests/test-rest-users-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ public function test_get_item_schema() {
$data = $response->get_data();
$properties = $data['schema']['properties'];

$this->assertEquals( 16, count( $properties ) );
$this->assertEquals( 17, count( $properties ) );
$this->assertArrayHasKey( 'avatar_urls', $properties );
$this->assertArrayHasKey( 'capabilities', $properties );
$this->assertArrayHasKey( 'description', $properties );
Expand All @@ -933,6 +933,7 @@ public function test_get_item_schema() {
$this->assertArrayHasKey( 'nickname', $properties );
$this->assertArrayHasKey( 'registered_date', $properties );
$this->assertArrayHasKey( 'slug', $properties );
$this->assertArrayHasKey( 'password', $properties );
$this->assertArrayHasKey( 'url', $properties );
$this->assertArrayHasKey( 'username', $properties );
$this->assertArrayHasKey( 'roles', $properties );
Expand Down Expand Up @@ -1051,6 +1052,8 @@ protected function check_user_data( $user, $data, $context ) {
$this->assertArrayNotHasKey( 'username', $data );
}

$this->assertArrayNotHasKey( 'password', $data );

}

protected function check_get_user_response( $response, $context = 'view' ) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.