Esempio n. 1
0
/**
 * Action method for completing the 'verify' action.  This action is used adding an identity URL to a
 * WordPress user through the admin interface.
 *
 * @param string $identity_url verified OpenID URL
 */
function openid_finish_verify($identity_url)
{
    if ($_REQUEST['action'] != 'verify') {
        return;
    }
    $user = wp_get_current_user();
    if (empty($identity_url)) {
        $message = openid_message();
        if (empty($message)) {
            openid_message('Unable to authenticate OpenID.');
        }
    } else {
        if (!openid_add_identity($user->ID, $identity_url)) {
            openid_message(__('OpenID assertion successful, but this URL is already associated with ' . 'another user on this blog. This is probably a bug.', 'openid'));
        } else {
            openid_message(sprintf(__('Added association with OpenID: %s', 'openid'), openid_display_identity($identity_url)));
            openid_status('success');
            // ensure that profile URL is a verified OpenID
            set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
            require_once 'Auth/OpenID.php';
            if ($GLOBALS['wp_version'] >= '2.3') {
                require_once ABSPATH . 'wp-admin/includes/admin.php';
            } else {
                require_once ABSPATH . WPINC . '/registration.php';
            }
            if (!openid_ensure_url_match($user)) {
                wp_update_user(array('ID' => $user->ID, 'user_url' => $identity_url));
                openid_message(openid_message() . '<br />' . __('<strong>Note:</strong> For security reasons, your profile URL has been updated to match your OpenID.', 'openid'));
            }
        }
    }
    return;
}
Esempio n. 2
0
function openid_add_user_identity($user_id, $identity_url)
{
    openid_add_identity($user_id, $identity_url);
}
/**
 * Action method for completing the 'verify' action.  This action is used adding an identity URL to a
 * WordPress user through the admin interface.
 *
 * @param string $identity_url verified OpenID URL
 */
function openid_finish_verify($identity_url, $action)
{
    if ($action != 'verify') {
        return;
    }
    $message;
    $user = wp_get_current_user();
    if (empty($identity_url)) {
        $message = openid_message();
        if (empty($message)) {
            $message = 1;
        }
    } else {
        if (!openid_add_identity($user->ID, $identity_url)) {
            $message = 2;
        } else {
            $message = 3;
            // ensure that profile URL is a verified OpenID
            set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
            require_once 'Auth/OpenID.php';
            require_once ABSPATH . 'wp-admin/includes/admin.php';
            if (!openid_ensure_url_match($user)) {
                wp_update_user(array('ID' => $user->ID, 'user_url' => $identity_url));
                $update_url = 1;
            }
        }
    }
    $finish_url = $_SESSION['openid_finish_url'];
    $finish_url = add_query_arg('status', openid_status(), $finish_url);
    $finish_url = add_query_arg('message', $message, $finish_url);
    if (isset($update_url) && $update_url) {
        $finish_url = add_query_arg('update_url', $update_url, $finish_url);
    }
    wp_safe_redirect($finish_url);
    exit;
}