/** * Checks if openid url already exists, outputs error; * Attempts to change user account to openid, outputs error on failure. * If global $openid_tmp_login is set logs out current temporary user. * Called from actions.php * * @param user object $user - the [potential] user to change to OpenID * @param string $url - the unique OpenID URL */ function openid_if_unique_change_account($user, $url) { global $openid_tmp_login; if (openid_already_exists($url)) { logout_tmpuser_error(get_string('auth_openid_url_exists', 'auth_openid', $url)); } else { if (!openid_change_user_account($user, $url, $openid_tmp_login)) { logout_tmpuser_error(get_string('auth_openid_login_error', 'auth_openid')); } } }
$authplugin = get_auth_plugin('openid'); switch ($action) { // Change an account type to OpenID case 'change': if ($mode != null) { // We need to print a confirmation message before proceeding $resp = $authplugin->process_response($_GET, true); if ($resp !== false) { $url = $resp->identity_url; $file = 'confirm_change.html'; } } elseif ($confirm) { if (!confirm_sesskey()) { error('Bad Session Key'); } else { openid_change_user_account($USER, $url); } } elseif ($cancel) { error(get_string('action_cancelled', 'auth_openid')); } elseif ($url != null) { if (openid_already_exists($url)) { error(get_string('auth_openid_url_exists', 'auth_openid', $url)); } else { $params['openid_action'] = 'change'; $authplugin->do_request(false, $CFG->wwwroot . '/auth/openid/actions.php', $params); } } break; // Append an OpenID url to an account // Append an OpenID url to an account case 'append':