示例#1
0
function rublon2factor_authenticate($user, $username, $password)
{
    $user = wp_authenticate_username_password($user, $username, $password);
    if (is_wp_error($user)) {
        return $user;
    } else {
        do_action('rublon_pre_authenticate', $user);
        $user_id = RublonHelper::getUserId($user);
        if (is_user_member_of_blog($user_id) && RublonHelper::isSiteRegistered()) {
            wp_logout();
            $remember = !empty($_POST['rememberme']);
            $authURL = RublonHelper::authenticateWithRublon($user, $remember);
            if (empty($authURL)) {
                if (RublonHelper::canShowBusinessEditionUpgradeBoxAfterLogin($user)) {
                    RublonHelper::setMessage('BUSINESS_EDITION_UPGRADE_BOX', 'updated', 'RC');
                }
                $levels = RublonRolesProtection::getProtectionTypesLevels();
                if ($levels[RublonHelper::getUserProtectionType()] >= $levels[RublonHelper::PROTECTION_TYPE_MOBILE]) {
                    $user_email = RublonHelper::getUserEmail($user);
                    $obfuscated_email = RublonHelper::obfuscateEmail($user_email);
                    RublonHelper::setMessage('ROLE_BLOCKED|' . base64_encode($obfuscated_email), 'error', 'LM');
                    $return_page = RublonHelper::getReturnPage();
                    wp_safe_redirect(wp_login_url($return_page));
                    exit;
                } else {
                    RublonHelper::setMobileUserStatus($user, RublonHelper::NO);
                    return $user;
                }
            } else {
                RublonHelper::setLoginToken($user);
                wp_redirect($authURL);
                exit;
            }
        } else {
            return $user;
        }
    }
}
示例#2
0
 static function isUserProtected()
 {
     $protection = RublonHelper::getUserProtectionType();
     return !empty($protection) and $protection != RublonHelper::PROTECTION_TYPE_NONE;
 }
示例#3
0
/**
 * 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;
    }
}