Forgot password broken
-
The current forgot password implementation is broken, it will always fail and result in the error “Password reset is not allowed for this user” no matter if the recaptcha has passed and the email is valid.
The following fixes the filter hook and return values
<?php /** * Class WC_Ncr_Lost_Password_Captcha */ class WC_Ncr_Lost_Password_Captcha extends WC_Ncr_No_Captcha_Recaptcha { public static function initialize() { // initialize if login is activated if ( isset( self::$plugin_options['captcha_wc_lost_password'] ) || self::$plugin_options['captcha_wc_lost_password'] == 'yes' ) { // adds the captcha to the login form add_filter( 'woocommerce_lostpassword_form', array( __CLASS__, 'display_captcha' ) ); // authenticate the captcha answer add_filter( 'allow_password_reset', array( __CLASS__, 'validate_lost_password_captcha'), 10, 2 ); } } /** * Verify the captcha answer. * * @return WP_Error */ public static function validate_lost_password_captcha( $allow, $user_id ) { if ( ! isset( $_POST['g-recaptcha-response'] ) || ! self::captcha_wc_verification() ) { return new WP_Error( 'empty_captcha', self::$error_message ); } return $allow; } }
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Forgot password broken’ is closed to new replies.