; } $this->plugin->all_errors_array['late_hook_errors'] = $msg; LoginFlowTransientStore::merge( array( 'errors_in_early_hook' => false ) ); return $msg; } /** * When returning from MFA with llar_mfa_error, inject an error so WordPress outputs the red #login_error block. * * @param \WP_Error $errors WP_Error object passed to login_header(). * @param string $redirect_to Redirect URL. * @return \WP_Error */ public function inject_mfa_return_login_error( $errors, $redirect_to ) { $llar_mfa_error = isset( $_GET['llar_mfa_error'] ) ? sanitize_text_field( wp_unslash( $_GET['llar_mfa_error'] ) ) : ''; if ( $llar_mfa_error !== '' ) { if ( ! is_wp_error( $errors ) ) { $errors = new \WP_Error(); } // The visitor already passed the password step and was sent to // the MFA app: a password error copy would be misleading here. $errors->add( 'llar_mfa_return', \LLAR\Core\MfaFlow\MfaFlowLoginHandler::refusal_message() ); } return $errors; } /** * Fix up the error message before showing it * * @param $content * * @return string */ public function fixup_error_messages( $content ) { global $limit_login_just_lockedout, $limit_login_nonempty_credentials, $limit_login_my_error_shown; $error_msg = $this->get_message(); $early_hook_msg = LoginFlowTransientStore::get( 'llar_early_hook_error_message', '' ); if ( $early_hook_msg !== '' && is_string( $early_hook_msg ) ) { $content = $early_hook_msg; LoginFlowTransientStore::merge( array( 'llar_early_hook_error_message' => null, 'errors_in_early_hook' => false, ) ); } else { $llar_mfa_error = isset( $_GET['llar_mfa_error'] ) ? sanitize_text_field( wp_unslash( $_GET['llar_mfa_error'] ) ) : ''; $show_mfa_return_error = ( $llar_mfa_error !== '' ); if ( $limit_login_nonempty_credentials ) { $content = ''; if ( $this->plugin->other_login_errors ) { foreach ( $this->plugin->other_login_errors as $msg ) { $content .= ! empty( $msg ) ? $msg . '
' : ''; } } else { /* Replace error message, including ours if necessary */ if ( ! empty( $_REQUEST['log'] ) && is_email( $_REQUEST['log'] ) ) { $content = __( 'ERROR: Incorrect email address or password.', 'limit-login-attempts-reloaded' ); } else { $content = __( 'ERROR: Incorrect username or password.', 'limit-login-attempts-reloaded' ); } } } elseif ( $show_mfa_return_error ) { /* Returning from the MFA app: the password step already succeeded, keep the two-factor copy. */ $content = \LLAR\Core\MfaFlow\MfaFlowLoginHandler::refusal_message(); } if ( ! empty( $error_msg ) ) { $content = $error_msg; } } $content = ! empty( $content ) ? '' . $content . '' : ''; $this->plugin->all_errors_array['late_hook_errors'] = $content; LoginFlowTransientStore::merge( array( 'errors_in_early_hook' => false ) ); return $content; } public function fixup_error_messages_wc( \WP_Error $error ) { $error->add( 1, __( 'WC Error', 'limit-login-attempts-reloaded' ) ); } /** * Return current (error) message to show, if any * * @return string */ public function get_message() { if ( LimitLoginAttempts::$cloud_app ) { $app_errors = LimitLoginAttempts::$cloud_app->get_errors(); return ! empty( $app_errors ) ? implode( '
', $app_errors ) : ''; } /* Check external whitelist */ if ( $this->ip_resolver->is_ip_whitelisted() ) { return ''; } /* Is lockout in effect? */ if ( ! $this->local_lockout->is_limit_login_ok() ) { return $this->error_msg(); } return ''; } }