public function apiRegistration() { $current_user = wp_get_current_user(); $email = RublonHelper::getUserEmail($current_user); $selector = '#wpadminbar'; $content = '<h3>' . __('Rublon API registration', 'rublon') . '</h3>'; $content .= '<div class="rublon-apireg-half-column rublon-apireg-description">'; $content .= '<p>' . __('Rublon Account Security works by talking to the Rublon API. This requires an API key, which needs to be generated specifically for your website.', 'rublon') . '</p>'; $content .= '<p>' . sprintf(__('Due to security reasons, this requires a registration with your email address: <strong>%s</strong>. In order to register with a different email address, change it in your <a href="%s">profile settings</a>.', 'rublon'), $email, admin_url('profile.php')) . '</p>'; $content .= '<fieldset class="rublon-apireg-fieldset"><label for="rublon-apireg-terms-agreed">' . '<input type="checkbox" id="rublon-apireg-terms-agreed" name="apiregTermsAgreed" value="1" />' . sprintf(__('I agree to the <a href="%s" target="_blank">Rublon API Terms of Service</a>', 'rublon'), 'https://developers.rublon.com/54/Terms-of-Service') . '</fieldset>'; $content .= '<fieldset class="rublon-apireg-fieldset"><label for="rublon-apireg-newsletter-signup">' . '<input type="checkbox" id="rublon-apireg-newsletter-signup" name="apiregNewsletterSignup" value="1" />' . __('Subscribe to our newsletter', 'rublon') . '</fieldset>'; $content .= '</div>'; $content .= '<div class="rublon-apireg-half-column rublon-apireg-image"><img src="' . RUBLON2FACTOR_PLUGIN_URL . '/assets/images/rublon_visual.gif" class="rublon-apireg-visual rublon-image" /></div>'; $content .= $this->_apireg_form; $options = array('content' => $content, 'position' => array('edge' => 'top', 'align' => 'center'), 'pointerClass' => 'wp-pointer rublon-apireg-pointer', 'pointerClassSelector' => '.wp-pointer.rublon-apireg-pointer', 'showFunction' => 'showApiRegPointer'); $dismiss_nonce = wp_create_nonce(self::API_REGISTRATION_DISMISSED); $buttons = array('button1' => array('text' => __('Cancel', 'rublon'), 'function' => 'RublonWP.pointers.apiReg.answer("no", ' . json_encode($dismiss_nonce) . ')', 'id' => 'rublon-apireg-button-cancel', 'close_on_click' => true), 'button2' => array('text' => __('Activate', 'rublon'), 'function' => 'RublonWP.pointers.apiReg.answer("yes", ' . json_encode($dismiss_nonce) . ')', 'additional_class' => 'disabled', 'id' => 'rublon-apireg-button-activate'), 'placement' => array('additional_class' => 'rublon-apireg-buttons', 'append_to' => '.rublon-apireg-description'), 'appearance' => array('connection' => 'before')); $other_settings = RublonHelper::getSettings('other'); if (!empty($other_settings[self::API_REGISTRATION_DISMISSED])) { $event_binding = ' $(document).ready(function() { RublonWP.pointers.apiReg.show = showApiRegPointer; RublonWP.pointers.apiReg.prepareHidden(); }); '; } else { $event_binding = ' if (rublon_pointer_options.position && rublon_pointer_options.position.defer_loading) { $(window).bind("load.wp-pointers", function() { RublonWP.pointers.apiReg.show = showApiRegPointer; showApiRegPointer(); RublonWP.pointers.apiReg.addBehaviour(); RublonWP.pointers.disableClicks(); }); } else { $(document).ready(function() { RublonWP.pointers.apiReg.show = showApiRegPointer; showApiRegPointer(); RublonWP.pointers.apiReg.addBehaviour(); RublonWP.pointers.disableClicks(); }); } '; } $constants_binding = ' RublonWP.pointers.apiReg.DISMISSED_ACTION = ' . json_encode(self::AJAX_API_REGISTRATION_ACTION) . '; RublonWP.pointers.apiReg.BUTTON_ACTIVATE_SELECTOR = "#" + ' . json_encode($buttons['button2']['id']) . '; '; $bindings = array($event_binding, $constants_binding); $this->_printPointer($selector, $options, $buttons, $bindings); }
public static function getInstance() { if (empty(self::$instance)) { $additional_settings = RublonHelper::getSettings('additional'); $current_user = wp_get_current_user(); self::$instance = new self(RublonHelper::getRublon(), RublonHelper::getUserId($current_user), RublonHelper::getUserEmail($current_user), $logout_listener = RublonHelper::isLogoutListenerEnabled()); // Embed consumer script if (RublonHelper::isSiteRegistered()) { add_action('wp_footer', array(self::$instance, 'renderConsumerScript'), PHP_INT_MAX); add_action('admin_footer', array(self::$instance, 'renderConsumerScript'), PHP_INT_MAX); } } return self::$instance; }
/** * Check mobile app status of a single WP user * * @param WP_User $user * @return string RublonHelper constant */ public function checkMobileStatus($user) { $user_id = RublonHelper::getUserId($user); $user_email = RublonHelper::getUserEmail($user); require_once dirname(__FILE__) . '/libs/RublonImplemented/RublonAPICheckProtection.php'; $check = new RublonAPICheckProtection($this->rublon, $user_id, $user_email); try { $check->perform(); } catch (RublonException $e) { $check = null; } if (!empty($check) && $check->isProtectionEnabled($user_id)) { $mobile_user_status = RublonHelper::YES; } else { $mobile_user_status = RublonHelper::NO; } return $mobile_user_status; }
protected function getProjectData() { $projectData = parent::getProjectData(); $projectData['project-description'] = get_bloginfo('description'); $projectData['plugin-version'] = RublonHelper::getCurrentPluginVersion(); $projectData['lang'] = RublonHelper::getBlogLanguage(); $current_user = wp_get_current_user(); $email = RublonHelper::getUserEmail($current_user); $projectData['project-owner-email'] = $email; $projectData['project-owner-email-hash'] = self::hash($email); $projectData[RublonConsumerRegistrationCommon::FIELD_PARTNER_KEY] = RublonHelper::getPartnerKey(); return $projectData; }
static function confirm(RublonConfirmStrategy $strategy, $dataKey) { try { $rublon = RublonHelper::getRublon(); $authUrl = $rublon->confirm(RublonHelper::getActionURL('confirm'), RublonHelper::getUserId(), RublonHelper::getUserEmail(), $strategy->getConfirmMessage(), self::getConfirmParams($strategy, $dataKey)); } catch (ForbiddenMethod_RublonAPIException $e) { RublonConfirmations::abortConfirmation('FORBIDDEN_METHOD'); } catch (RublonException $e) { // echo $e->getClient()->getRawRequest();exit; RublonHelper::_handleCallbackException($e); RublonConfirmations::abortConfirmation('API_ERROR'); } if (!empty($authUrl)) { wp_redirect($authUrl); exit; } else { // Why empty? if ($roleProtectionType == RublonHelper::PROTECTION_TYPE_MOBILE) { // Mobile App is required: RublonConfirmations::abortConfirmation('MOBILE_APP_REQUIRED'); } else { // Rublon is not working at this moment or user is not protected: self::redirectParentFrame($_SERVER['REQUEST_URI'], $strategy->getAction(), __('Please wait.', 'rublon'), $dataKey); } } }
/** * Get current user's email. * * @return string */ protected function getUserEmail() { $current_user = wp_get_current_user(); return RublonHelper::getUserEmail($current_user); }
function rublon2factor_dismiss_api_registration() { $post = $_POST; $other_settings = RublonHelper::getSettings('other'); if (!empty($post['nonce']) && wp_verify_nonce($post['nonce'], Rublon_Pointers::API_REGISTRATION_DISMISSED)) { $other_settings[Rublon_Pointers::API_REGISTRATION_DISMISSED] = RublonHelper::YES; $current_user = wp_get_current_user(); if (!empty($post['newsletter_signup']) && $post['newsletter_signup'] == 'true') { $other_settings['newsletter_signup'] = array(RublonHelper::getUserEmail($current_user)); } RublonHelper::saveSettings($other_settings, 'other'); } }
function pluginsLoaded() { parent::pluginsLoaded(); if ($this->isTheAction() and RublonConfirmations::$dataRestored or !$this->isConfirmationRequired()) { // Update user protection type $current_user = wp_get_current_user(); if (!empty($_POST[RublonHelper::FIELD_USER_PROTECTION_TYPE]) and $_POST[RublonHelper::FIELD_USER_PROTECTION_TYPE] != RublonHelper::userProtectionType($current_user)) { RublonHelper::setUserProtectionType($current_user, $_POST[RublonHelper::FIELD_USER_PROTECTION_TYPE]); } if (!empty($_POST['email']) && $_POST['email'] !== RublonHelper::getUserEmail($current_user)) { RublonHelper::clearMobileUserStatus($current_user); } } }