Return early if another plugin has already declared an auth failure

This commit is contained in:
James Collins 2020-09-22 16:17:35 +08:00
parent b84080c67e
commit ce31260452
No known key found for this signature in database
GPG Key ID: 0669E767111C190F
1 changed files with 4 additions and 0 deletions

View File

@ -102,6 +102,10 @@ class WC_REST_Authentication {
* @return WP_Error|null|bool
*/
public function authentication_fallback( $error ) {
if ( ! empty( $error ) ) {
// Another plugin has already declared a failure.
return $error;
}
if ( empty( $this->error ) && empty( $this->auth_method ) && empty( $this->user ) && 0 === get_current_user_id() ) {
// Authentication hasn't occurred during `determine_current_user`, so check auth.
$user_id = $this->authenticate( false );