This commit is contained in:
Javier Casares 2026-08-24 08:18:14 +00:00
commit 511d2fefae

View file

@ -233,6 +233,46 @@ class Login_Form_Manager {
add_filter( 'login_message', array( $this, 'filter_login_message' ) );
add_filter( 'authenticate', array( $this, 'maybe_complete_verification' ), 5, 3 );
add_filter( 'authenticate', array( $this, 'enforce_verification_challenge' ), 30, 3 );
add_action( 'init', array( $this, 'maybe_remove_altcha_interceptor' ), 0 );
}
/**
* Disable the ALTCHA Spam Protection login interceptor during the 2FA stage.
*
* ALTCHA's "Protect login" feature rejects any wp-login.php POST that does
* not carry a fresh proof-of-work payload (HTTP 403). Its JavaScript only
* produces that payload for classic username + password submissions, while
* the verification stage intentionally omits the password field, so every
* legitimate 2FA submission would otherwise be blocked. Human verification
* already happened on the first login step; this stage is protected by the
* pending-stage token, the stage nonce, and the failed-attempts lockout.
*
* @since 1.6.2
*
* @return void
*/
public function maybe_remove_altcha_interceptor(): void {
if ( ! $this->is_verification_stage() ) {
return;
}
if ( ! has_action( 'init', 'altcha_interceptor' ) ) {
return;
}
global $wp_filter;
if ( ! isset( $wp_filter['init'] ) || ! $wp_filter['init'] instanceof \WP_Hook ) {
return;
}
foreach ( array_keys( $wp_filter['init']->callbacks ) as $priority ) {
if ( isset( $wp_filter['init']->callbacks[ $priority ]['altcha_interceptor'] ) ) {
remove_action( 'init', 'altcha_interceptor', (int) $priority );
return;
}
}
}
/**