| @@ -39,8 +39,9 @@ | ||
| 39 | 39 | if ( class_exists( 'WooCommerce' ) ) { |
| 40 | 40 | add_action( 'woocommerce_login_form_start', [ $this, 'add_captcha' ] ); |
| 41 | 41 | add_action( 'woocommerce_register_form_start', [ $this, 'add_captcha' ] ); |
| 42 | 42 | add_action( 'wp_authenticate', [ $this, 'add_captcha' ] ); |
| 43 | + add_filter( 'woocommerce_process_registration_errors', [$this, 'general_captcha_check' ], 10, 1 ); | |
| 43 | 44 | add_action( 'woocommerce_before_lost_password_form', [ $this, 'add_captcha' ] ); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | // 2FA related actions. |
| @@ -174,10 +175,9 @@ | ||
| 174 | 175 | |
| 175 | 176 | // Verify the code. |
| 176 | 177 | require_once dirname( __FILE__ ) . '/2fa/rfc6238.php'; |
| 177 | 178 | $secret = $this->tfa_get_secret( $user ); |
| 178 | - $code = isset( $_POST['patchstack_2fa_secretkey_verification'] ) ? trim( $_POST['patchstack_2fa_secretkey_verification'] ) : ''; | |
| 179 | - if ( ! TokenAuth6238::verify( $secret, $code ) ) { | |
| 179 | + if ( ! TokenAuth6238::verify( $secret, trim( $_POST['patchstack_2fa_secretkey_verification'] ) ) ) { | |
| 180 | 180 | wc_add_notice( __( 'The 2FA authentication code you entered is invalid.', 'patchstack' ), 'error' ); |
| 181 | 181 | return; |
| 182 | 182 | } |
| 183 | 183 | |
| @@ -329,9 +329,8 @@ | ||
| 329 | 329 | if ( $this->get_option( 'patchstack_captcha_registration_form' ) ) { |
| 330 | 330 | add_action( 'register_form', [ $this->plugin->hardening, 'captcha_display' ] ); |
| 331 | 331 | add_action( 'woocommerce_register_form', [ $this->plugin->hardening, 'captcha_display' ] ); |
| 332 | 332 | add_action( 'registration_errors', [ $this, 'general_captcha_check' ] ); |
| 333 | - add_filter( 'woocommerce_process_registration_errors', [$this, 'general_captcha_check' ], 10, 1 ); | |
| 334 | 333 | } |
| 335 | 334 | |
| 336 | 335 | // reCAPTCHA on the reset password form. |
| 337 | 336 | if ( $this->get_option( 'patchstack_captcha_reset_pwd_form' ) ) { |