Skip to content

Commit

Permalink
Fix php lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Jul 15, 2021
1 parent 02fff5a commit 080271d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/e2e-tests/mu-plugins/basic-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@
* @package gutenberg-test-basic-auth
*/

/**
* Handles basic auth for REST API.
*
* @param WP_User $user The current user.
* @return string The user ID.
*/
function json_basic_auth_handler( $user ) {
global $wp_json_basic_auth_error;

$wp_json_basic_auth_error = null;

// Don't authenticate twice
// Don't authenticate twice.
if ( ! empty( $user ) ) {
return $user;
}

// Check that we're trying to authenticate
if ( !isset( $_SERVER['PHP_AUTH_USER'] ) ) {
// Check that we're trying to authenticate.
if ( ! isset( $_SERVER['PHP_AUTH_USER'] ) ) {
return $user;
}

Expand Down Expand Up @@ -51,8 +57,14 @@ function json_basic_auth_handler( $user ) {
}
add_filter( 'determine_current_user', 'json_basic_auth_handler', 20 );

/**
* Handle auth errors.
*
* @param WP_Error $error The REST API authentication error.
* @return WP_Error The REST API authentication error.
*/
function json_basic_auth_error( $error ) {
// Passthrough other errors
// Passthrough other errors.
if ( ! empty( $error ) ) {
return $error;
}
Expand Down

0 comments on commit 080271d

Please sign in to comment.