function saml_error($err, $urltogo = false, $logfile = '') { global $CFG, $PAGE, $OUTPUT; if (!isset($CFG->debugdisplay) || !$CFG->debugdisplay) { $debug = false; } else { $debug = true; } if ($urltogo != false) { $site = get_site(); if ($site === false || !isset($site->fullname)) { $site_name = ''; } else { $site_name = $site->fullname; } $PAGE->set_title($site_name . ':Error SAML Login'); echo $OUTPUT->header(); echo '<div style="margin:20px;font-weight: bold; color: red;">'; } if (is_array($err)) { foreach ($err as $key => $messages) { if (!is_array($messages)) { if ($urltogo != false && ($debug || $key == 'course_enrollment')) { echo $messages; } $msg = 'Moodle SAML module: ' . $key . ': ' . $messages; log_saml_error($msg, $logfile); } else { foreach ($messages as $message) { if ($urltogo != false && ($debug || $key == 'course_enrollment')) { echo $message . '<br>'; } $msg = 'Moodle SAML module: ' . $key . ': ' . $message; log_saml_error($msg, $logfile); } } echo '<br>'; } } else { if ($urltogo != false) { echo $err; } $msg = 'Moodle SAML module: login: '******'</div>'; $OUTPUT->continue_button($urltogo); if ($debug) { print_string("auth_saml_disable_debugdisplay", "auth_saml"); } $OUTPUT->footer(); exit; } }
$valid_saml_session = $as->isAuthenticated(); $saml_attributes = $as->getAttributes(); } catch (Exception $e) { session_write_close(); require_once '../../config.php'; require_once 'error.php'; global $CFG, $err, $PAGE, $OUTPUT; $PAGE->set_url('/auth/saml/index.php'); $PAGE->set_context(CONTEXT_SYSTEM::instance()); $pluginconfig = get_config('auth/saml'); $urltogo = $CFG->wwwroot; if ($CFG->wwwroot[strlen($CFG->wwwroot) - 1] != '/') { $urltogo .= '/'; } $err['login'] = $e->getMessage(); log_saml_error('Moodle SAML module:' . $err['login'], $pluginconfig->samllogfile); saml_error($err['login'], $urltogo, $pluginconfig->samllogfile); } // Now we close simpleSAMLphp session session_write_close(); // We load all moodle config and libs require_once '../../config.php'; require_once 'error.php'; global $CFG, $USER, $SAML_COURSE_INFO, $SESSION, $err, $DB, $PAGE; $PAGE->set_url('/auth/saml/index.php'); $PAGE->set_context(CONTEXT_SYSTEM::instance()); $urltogo = $CFG->wwwroot; if ($CFG->wwwroot[strlen($CFG->wwwroot) - 1] != '/') { $urltogo .= '/'; } // set return rul from wantsurl