protected function finalSuccess() { parent::finalSuccess(); $this->updateRublonSettings(); $updateMessage = 'PLUGIN_REGISTERED'; RublonHelper::setMessage($updateMessage, 'updated', 'CR'); RublonCookies::setAuthCookie(); $pluginMeta = RublonHelper::preparePluginMeta(); $pluginMeta['action'] = 'activation'; RublonHelper::pluginHistoryRequest($pluginMeta); $other_settings = RublonHelper::getSettings('other'); if (!empty($other_settings['newsletter_signup'])) { foreach ($other_settings['newsletter_signup'] as $email) { $rublon_req = new RublonRequests(); $rublon_req->subscribeToNewsletter($email); } unset($other_settings['newsletter_signup']); RublonHelper::saveSettings($other_settings, 'other'); } // Save project owner information RublonHelper::saveProjectOwner(); // Clear features cache if it is not a Business Editions RublonFeature::getFeatures(false); if (!RublonFeature::isBusinessEdition()) { RublonFeature::deleteFeaturesFromCache(); } $this->_redirect(admin_url(RublonHelper::WP_RUBLON_PAGE)); }
static function getConfirmParams(RublonConfirmStrategy $strategy, $dataKey) { $params = array(); $context = $strategy->getContext(); $protectionType = RublonHelper::getUserProtectionType(); switch ($protectionType) { case RublonHelper::PROTECTION_TYPE_MOBILE_EVERYTIME: $params[RublonAuthParams::FIELD_IGNORE_TRUSTED_DEVICE] = true; $params[RublonAuthParams::FIELD_CAN_USE_EMAIL2FA] = false; break; case RublonHelper::PROTECTION_TYPE_MOBILE: $params[RublonAuthParams::FIELD_CAN_USE_EMAIL2FA] = false; break; case RublonHelper::PROTECTION_TYPE_EMAIL: $params[RublonAuthParams::FIELD_CAN_USE_EMAIL2FA] = true; break; default: $params[RublonAuthParams::FIELD_CAN_USE_EMAIL2FA] = false; } if ($timeBuffer = RublonFeature::getBufferedConfirmationTime()) { $params[RublonAuthParams::FIELD_CONFIRM_TIME_BUFFER] = $timeBuffer * 60; } $params[self::PARAM_ACTION] = $strategy->getAction(); $params[self::PARAM_DATA_KEY] = $dataKey; $params[self::PARAM_ACTION_URL] = $_SERVER['REQUEST_URI']; $params[self::PARAM_FALLBACK_URL] = self::getFallbackUrl($strategy); if (empty($params[self::PARAM_FALLBACK_URL])) { $params[self::PARAM_FALLBACK_URL] = $params[self::PARAM_ACTION_URL]; } $params[RublonAuthParams::FIELD_CUSTOM_URI_PARAM] = self::CUSTOM_URI_PARAM_PREFIX . $params[self::PARAM_FALLBACK_URL]; return $params; }
function rublon2factor_user_new_form() { $roles = get_editable_roles(); $roles_js = array(); $roles_js['protection_levels'] = array(); foreach ($roles as $role_name => $role) { $role_id = RublonHelper::prepareRoleId(esc_attr($role_name)); $settings = RublonHelper::getSettings('additional'); $role_protection_type = !empty($settings[$role_id]) ? $settings[$role_id] : ''; switch ($role_protection_type) { case RublonHelper::PROTECTION_TYPE_MOBILE: $role_protection_level = 2; break; case RublonHelper::PROTECTION_TYPE_EMAIL: $role_protection_level = 1; break; default: $role_protection_level = 0; } $roles_js['protectionLevels'][esc_attr($role_name)] = $role_protection_level; } echo '<label class="hidden rublon-label rublon-label-newuserrole" for="rublon-newuserrole-dropdown">'; echo ' <div class="rublon-lock-container rublon-locked-container rublon-newuserrole-locked"><img class="rublon-lock rublon-locked" src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/locked.png" /></div>'; echo '</label>'; if (RublonFeature::isBusinessEdition()) { echo '<div class="hidden rublon-secured-role-description"><span class="description">' . sprintf(__('The new user account will be automatically protected by <a href="%s" target="_blank">Rublon</a>.', 'rublon'), RublonHelper::rubloncomUrl()) . '</span></div>'; echo '<script>//<![CDATA[ document.addEventListener(\'DOMContentLoaded\', function() { if (RublonWP) { RublonWP.roleProtectionLevels = ' . json_encode($roles_js) . '; RublonWP.setUpNewUserRoleChangeListener("your-profile", "rublon-confirmation-form"); } }, false); //]]></script>'; } }
/** * Handle the additional Rublon columns for a given user * * @param mixed $value Current column value * @param string $column_name Column name * @param int $user_id User's ID * @return string */ function rublon2factor_manage_rublon_columns($value, $column_name, $user_id) { if (RublonHelper::isSiteRegistered()) { // Retrieve Rublon users from prerender data. $rublon_mobile_users = RublonHelper::getPrerenderData(RublonHelper::PRERENDER_KEY_MOBILE_USERS); if ($column_name == 'rublon2factor_status') { $user = get_user_by('id', $user_id); $protectionType = array(RublonHelper::roleProtectionType($user), RublonHelper::userProtectionType($user)); if (RublonHelper::isPersonalEdition() && RublonHelper::isProjectOwner($user_id) || RublonFeature::isBusinessEdition() && RublonRolesProtection::isGrater(RublonHelper::getUserProtectionType($user), RublonHelper::PROTECTION_TYPE_NONE)) { $lang = RublonHelper::getBlogLanguage(); $value = sprintf('<a href="%s"', RublonHelper::rubloncomUrl()) . ' target="_blank"><img class="rublon-protected rublon-image" src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/rublon_logo_32x32.png' . '" title="' . __('Account protected by Rublon', 'rublon') . '" /></a>'; } } return $value; } }
/** * Check if given protection type is available for this consumer. * * @param string $type * @return boolean */ static function isProtectionTypeAvailable($type) { $forceMobileApp = RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_FORCE_MOBILE_APP); switch ($type) { case RublonHelper::PROTECTION_TYPE_MOBILE: return $forceMobileApp; case RublonHelper::PROTECTION_TYPE_MOBILE_EVERYTIME: return $forceMobileApp and RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_IGNORE_TRUSTED_DEVICE); default: return true; } }
function isConfirmationRequired() { return RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_OPERATION_CONFIRMATION) and (!$this->hasAdminUI() or in_array($this->getAction(), RublonConfirmations::getSettings())); }
/** * Check if this is a Business Edition. * * @return boolean */ static function isBusinessEdition() { return RublonFeature::checkFeature(RublonAPIGetAvailableFeatures::FEATURE_FLAG_BUSINESS_EDITION); }