Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addresses #12 in WP-API/Basic-Auth so you can use basic auth AND be l… #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions basic-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ function json_basic_auth_handler( $user ) {
}

$wp_json_basic_auth_error = true;

//if we found a user, remove regular cookie filters because
//they're just going to overwrite what we've found
if( $user->ID ){
remove_filter( 'determine_current_user', 'wp_validate_auth_cookie' );
remove_filter( 'determine_current_user', 'wp_validate_logged_in_cookie', 20 );
}
return $user->ID;
}
add_filter( 'determine_current_user', 'json_basic_auth_handler', 20 );
add_filter( 'determine_current_user', 'json_basic_auth_handler', 5 );

function json_basic_auth_error( $error ) {
// Passthrough other errors
Expand Down