示例#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;
        }
    }
}