/** * Disconnect from o365. */ public function mode_disconnecttoken() { global $CFG; require_once $CFG->dirroot . '/auth/oidc/auth.php'; $auth = new \auth_plugin_oidc(); $auth->set_httpclient(new \auth_oidc\httpclient()); $redirect = new \moodle_url('/local/o365/ucp.php'); $auth->disconnect(true, $redirect); }
$oidcloginconnected = $USER->auth === 'oidc' ? true : false; if (!empty($action)) { if ($action === 'connectlogin' && $oidcloginconnected === false) { // Use authorization request login flow to connect existing users. if (!is_enabled_auth('oidc')) { throw new \moodle_exception('erroroidcnotenabled', 'auth_oidc'); } $auth = new \auth_oidc\loginflow\authcode(); $auth->set_httpclient(new \auth_oidc\httpclient()); $auth->initiateauthrequest(); } else { if ($action === 'disconnectlogin' && $oidcloginconnected === true) { if (is_enabled_auth('manual') === true) { $auth = new \auth_plugin_oidc(); $auth->set_httpclient(new \auth_oidc\httpclient()); $auth->disconnect(); } } else { throw new \moodle_exception('errorucpinvalidaction', 'auth_oidc'); } } } else { $PAGE->set_url('/auth/oidc/ucp.php'); $usercontext = \context_user::instance($USER->id); $PAGE->set_context(\context_system::instance()); $PAGE->set_pagelayout('standard'); $USER->editing = false; $authconfig = get_config('auth_oidc'); $opname = !empty($authconfig->opname) ? $authconfig->opname : get_string('pluginname', 'auth_oidc'); $ucptitle = get_string('ucp_title', 'auth_oidc', $opname); $PAGE->navbar->add($ucptitle, $PAGE->url);