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; }
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); } } }
/** * Constructor */ public function __construct() { $this->rublon = RublonHelper::getRublon(); }
/** * Render hidden elements to be used later in the iframe layer */ function rublon2factor_show_user_profile() { if (RublonHelper::isSiteRegistered()) { // echo '<script>//<![CDATA[ // document.addEventListener(\'DOMContentLoaded\', function() { // if (RublonWP) { // RublonWP.setUpFormSubmitListener("your-profile", "rublon-confirmation-form"); // } // }, false); // //]]></script>'; $current_user = wp_get_current_user(); echo new RublonConsumerScript(RublonHelper::getRublon(), RublonHelper::getUserId($current_user), RublonHelper::getUserEmail($current_user)); if (RublonFeature::isBusinessEdition() && $current_user && $current_user instanceof WP_User) { // Rublon Protection section RublonHelper::printProfileSectionAdditions($current_user); } } }
/** * Get the features list from Rublon server. * * @return NULL|array */ static function getFeaturesFromServer() { if (!RublonHelper::isSiteRegistered()) { return null; } try { $client = new RublonAPIGetAvailableFeatures(RublonHelper::getRublon()); $client->perform(); return $client->getFeatures(); } catch (RublonException $e) { return null; } }