| @@ -111,9 +111,9 @@ | ||
| 111 | 111 | if ( $this->model->is_active() ) { |
| 112 | 112 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 113 | 113 | $is_jetpack_sso = $this->service->is_jetpack_sso(); |
| 114 | 114 | $is_tml = $this->service->is_tml(); |
| 115 | - add_action( 'admin_init', array( $this->service, 'get_providers' ) ); | |
| 115 | + add_action( 'admin_init', array( $this, 'load_providers' ) ); | |
| 116 | 116 | add_action( 'pre_get_users', array( $this, 'filter_users_by_2fa' ) ); |
| 117 | 117 | add_action( 'show_user_profile', array( $this, 'show_user_profile' ) ); |
| 118 | 118 | add_action( 'profile_update', array( $this, 'profile_update' ) ); |
| 119 | 119 | |
| @@ -173,8 +173,17 @@ | ||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | + * Loads the available service providers. | |
| 178 | + * | |
| 179 | + * @return void | |
| 180 | + */ | |
| 181 | + public function load_providers(): void { | |
| 182 | + $this->service->get_providers(); | |
| 183 | + } | |
| 184 | + | |
| 185 | + /** | |
| 177 | 186 | * Checks if WooCommerce integration is enabled. |
| 178 | 187 | * |
| 179 | 188 | * @return bool Whether WooCommerce integration is enabled. |
| 180 | 189 | */ |
| @@ -329,8 +338,9 @@ | ||
| 329 | 338 | } elseif ( $this->password_protection_service->is_force_reset( $user ) ) { |
| 330 | 339 | $this->password_protection_service->do_force_reset( $user, $password ); |
| 331 | 340 | } else { |
| 332 | 341 | $user_id = $user->ID; |
| 342 | + // For the Webauthn method, the check occurs inside Webauthn_Controller::verify_response(). | |
| 333 | 343 | // Set active user. |
| 334 | 344 | wp_set_current_user( $user_id, $user->user_login ); |
| 335 | 345 | // Todo: add code for 'rememberme'-option. |
| 336 | 346 | wp_set_auth_cookie( $user_id, true ); |
| @@ -889,13 +899,24 @@ | ||
| 889 | 899 | * @return Response |
| 890 | 900 | * @defender_route |
| 891 | 901 | */ |
| 892 | 902 | public function save_settings( Request $request ): Response { |
| 893 | - $model = $this->model; | |
| 894 | - $data = $request->get_data(); | |
| 903 | + $model = $this->model; | |
| 904 | + $data = $request->get_data(); | |
| 905 | + $old_detect_woo = $model->detect_woo; | |
| 906 | + | |
| 895 | 907 | $model->import( $data ); |
| 896 | 908 | if ( $model->validate() ) { |
| 897 | 909 | $model->save(); |
| 910 | + | |
| 911 | + if ( $old_detect_woo !== $model->detect_woo ) { | |
| 912 | + if ( $model->detect_woo ) { | |
| 913 | + $this->wp_defender_2fa_endpoint(); | |
| 914 | + } | |
| 915 | + | |
| 916 | + flush_rewrite_rules(); | |
| 917 | + } | |
| 918 | + | |
| 898 | 919 | Config_Hub_Helper::set_clear_active_flag(); |
| 899 | 920 | |
| 900 | 921 | return new Response( |
| 901 | 922 | true, |
| @@ -1098,9 +1119,8 @@ | ||
| 1098 | 1119 | } |
| 1099 | 1120 | } |
| 1100 | 1121 | |
| 1101 | 1122 | /** |
| 1102 | - * Todo: add changes when the design is ready. | |
| 1103 | 1123 | * Provides data for the frontend. |
| 1104 | 1124 | * |
| 1105 | 1125 | * @return array An array of data for the frontend. |
| 1106 | 1126 | */ |
| @@ -1333,9 +1353,8 @@ | ||
| 1333 | 1353 | * @return void |
| 1334 | 1354 | */ |
| 1335 | 1355 | public function wp_defender_2fa_endpoint(): void { |
| 1336 | 1356 | add_rewrite_endpoint( $this->slug, EP_PERMALINK | EP_PAGES ); |
| 1337 | - flush_rewrite_rules(); | |
| 1338 | 1357 | } |
| 1339 | 1358 | |
| 1340 | 1359 | /** |
| 1341 | 1360 | * 2. dds the slug of the current instance to the given array of query variables. |