PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/controller/class-password-protection.php +9 -28 5.8.1 → 6.3.0 View file →
@@ -49,9 +49,8 @@
49 49 $this->model = wd_di()->get( \WP_Defender\Model\Setting\Password_Protection::class );
50 50 $this->service = wd_di()->get( \WP_Defender\Component\Password_Protection::class );
51 51 $default_values = $this->model->get_default_values();
52 52 $this->default_msg = $default_values['message'];
53 - add_filter( 'wp_defender_advanced_tools_data', array( $this, 'script_data' ) );
54 53 $this->register_routes();
55 54 if ( $this->model->is_active() ) {
56 55 // Update site url on sub-site when MaskLogin is disabled.
57 56 if (
@@ -59,9 +58,9 @@
59 58 && ! wd_di()->get( \WP_Defender\Model\Setting\Mask_Login::class )->is_active()
60 59 ) {
61 60 add_filter( 'network_site_url', array( $this, 'filter_site_url' ), 100, 2 );
62 61 }
63 - add_action( 'wp_authenticate_user', array( $this, 'handle_login_password' ), 100, 2 );
62 + add_filter( 'wp_authenticate_user', array( $this, 'handle_login_password' ), 100, 2 );
64 63 add_action( 'validate_password_reset', array( $this, 'handle_reset_check_password' ), 100, 2 );
65 64 add_action( 'user_profile_update_errors', array( $this, 'handle_profile_update_password' ), 1, 3 );
66 65 if ( wd_di()->get( Woocommerce::class )->is_wc_login_context() ) {
67 66 add_filter( 'woocommerce_reset_password_message', array( $this->service, 'add_woocommerce_error_message' ) );
@@ -118,11 +117,11 @@
118 117 *
119 118 * @param WP_Error $errors Error object.
120 119 * @param WP_User|WP_Error $user WP_User object or WP_Error.
121 120 *
122 - * @return void|WP_Error
121 + * @return void
123 122 */
124 - public function handle_reset_check_password( WP_Error $errors, $user ) {
123 + public function handle_reset_check_password( WP_Error $errors, $user ): void {
125 124 if ( is_wp_error( $user ) ) {
126 125 return;
127 126 }
128 127
@@ -145,9 +144,9 @@
145 144 $login_password = $this->service->get_submitted_password();
146 145 if ( $login_password ) {
147 146 $is_pwned = $this->service->check_pwned_password( $login_password );
148 147 if ( is_wp_error( $is_pwned ) ) {
149 - return $errors;
148 + return;
150 149 }
151 150
152 151 if ( $is_pwned ) {
153 152 $message = ! isset( $this->model->pwned_actions['force_change_message'] )
@@ -157,10 +156,8 @@
157 156 : $this->model->pwned_actions['force_change_message'];
158 157 $errors->add( 'defender_password_protection', $message );
159 158 }
160 159 }
161 -
162 - return $errors;
163 160 }
164 161
165 162 /**
166 163 * Handle password update on new user registration and user profile update.
@@ -168,11 +165,11 @@
168 165 * @param WP_Error $errors The errors object to add error messages to.
169 166 * @param bool $update Whether the profile is being updated.
170 167 * @param stdClass $user The user object being updated.
171 168 *
172 - * @return WP_Error The updated errors object.
169 + * @return void
173 170 */
174 - public function handle_profile_update_password( WP_Error $errors, bool $update, stdClass $user ) {
171 + public function handle_profile_update_password( WP_Error $errors, bool $update, stdClass $user ): void {
175 172 if ( $errors->get_error_message( 'pass' ) ||
176 173 is_wp_error( $user ) ||
177 174 ! isset( $user->user_pass )
178 175 ) {
@@ -187,9 +184,9 @@
187 184 $login_password = $this->service->get_submitted_password();
188 185 if ( $login_password ) {
189 186 $is_pwned = $this->service->check_pwned_password( $login_password );
190 187 if ( is_wp_error( $is_pwned ) ) {
191 - return $errors;
188 + return;
192 189 }
193 190
194 191 if ( $is_pwned ) {
195 192 $message = ! isset( $this->model->pwned_actions['force_change_message'] )
@@ -199,10 +196,8 @@
199 196 : $this->model->pwned_actions['force_change_message'];
200 197 $errors->add( 'defender_password_protection', $message );
201 198 }
202 199 }
203 -
204 - return $errors;
205 200 }
206 201
207 202 /**
208 203 * Get model.
@@ -217,21 +212,8 @@
217 212 return new \WP_Defender\Model\Setting\Password_Protection();
218 213 }
219 214
220 215 /**
221 - * Provide data to the frontend via localized script.
222 - *
223 - * @param array $data Data collection is ready to passed.
224 - *
225 - * @return array Modified data array with added this controller data.
226 - */
227 - public function script_data( array $data ): array {
228 - $data['password_protection'] = $this->data_frontend();
229 -
230 - return $data;
231 - }
232 -
233 - /**
234 216 * Save settings.
235 217 *
236 218 * @param Request $request The request object containing new settings data.
237 219 *
@@ -394,16 +376,15 @@
394 376 );
395 377 }
396 378
397 379 /**
398 - * Generates configuration strings based on the provided configuration and whether the product is a pro version.
380 + * Generates configuration strings based on the provided configuration.
399 381 *
400 382 * @param mixed $config The configuration data.
401 - * @param bool $is_pro Indicates if the product is a pro version.
402 383 *
403 384 * @return array Returns an array of configuration strings.
404 385 */
405 - public function config_strings( $config, bool $is_pro ): array {
386 + public function config_strings( $config ): array {
406 387 $is_enabled = isset( $config['enabled'] ) ? (bool) $config['enabled'] : false;
407 388 if (
408 389 ! $is_enabled ||
409 390 ! isset( $config['user_roles'] ) ||