request = $request; $this->legacy_mode_checker = $legacy_mode_checker; } /** * @param null|WP_Error|WP_User $user * * @return bool */ public function supports( $user ) { try { $this->get_wp_user(); } catch ( User_Not_Found_Exception $e ) { return false; } return $this->check_conditions(); } /** * @param null|WP_Error|WP_User $user * * @return bool|JSON_Response|Redirection_Response|View_Response */ protected function handle( $user ) { $final_response = $this->json_error( Errors::DISABLED_OBLIGATORY_2FA, 403 ); $this->login_support->set_final_response( $final_response ); return $this->fallback( $user ); } /** * @return bool */ private function check_conditions() { return $this->validate_action() && ! $this->legacy_mode_checker->totp_is_obligatory_or_legacy_mode_is_active(); } /** * @return bool */ private function validate_action() { return $this->request->is_login_action_equal_to( Login_Action::TOTP_CONFIRMATION ) || $this->request->is_login_action_equal_to( Login_Action::TOTP_RESET ) || $this->request->is_login_action_equal_to( Login_Action::CONFIGURE ); } }