Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Check parameters in the correct place
Browse files Browse the repository at this point in the history
Update doesn't require the user data, creation does.
  • Loading branch information
rmccue committed Jun 3, 2014
1 parent 90376f6 commit 15bb5a0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/class-wp-json-users.php
Expand Up @@ -234,14 +234,6 @@ protected function insert_user( $data ) {
return new WP_Error( 'json_user_cannot_edit', __( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => 403 ) );
}

$required = array( 'username', 'password', 'email' );

foreach ( $required as $arg ) {
if ( empty( $data[ $arg ] ) ) {
return new WP_Error( 'json_missing_callback_param', sprintf( __( 'Missing parameter %s' ), $arg ), array( 'status' => 400 ) );
}
}

$update = true;
} else {
$user = new WP_User();
Expand All @@ -253,6 +245,14 @@ protected function insert_user( $data ) {
return new WP_Error( 'json_cannot_create', __( 'Sorry, you are not allowed to create users.' ), array( 'status' => 403 ) );
}

$required = array( 'username', 'password', 'email' );

foreach ( $required as $arg ) {
if ( empty( $data[ $arg ] ) ) {
return new WP_Error( 'json_missing_callback_param', sprintf( __( 'Missing parameter %s' ), $arg ), array( 'status' => 400 ) );
}
}

$update = false;
}

Expand Down

0 comments on commit 15bb5a0

Please sign in to comment.