diff --git a/auth.php b/auth.php
index ac1c19a..e0dd925 100755
--- a/auth.php
+++ b/auth.php
@@ -175,7 +175,7 @@ function config_form($config, $err, $user_fields) {
$dbman = $DB->get_manager();
$table_course_mapping = $this->get_course_mapping_xmldb();
- $table_role_mapping = $this->get_role_mapping_xmldb();
+ $table_role_mapping = $this->get_role_mapping_xmldb();
if(isset($config->supportcourses) && $config->supportcourses == 'internal') {
if(!$dbman->table_exists($table_course_mapping)) {
@@ -216,9 +216,9 @@ function validate_form($form, &$err) {
}
if ($form->supportcourses == 'external') {
- if ($form->externalcoursemappingdsn == '' || $form->externalcoursemappingsql == '' || $form->externalrolemappingdsn == '' || $form->externalrolemappingsql == '') {
+ if ($form->externalcoursemappingdsn == '' || $form->externalcoursemappingsql == '' || $form->externalrolemappingdsn == '' || $form->externalrolemappingsql == '') {
$err['samlexternal'] = get_string('auth_saml_errorsamlexternal', 'auth_saml', $form->samllib);
- }
+ }
}
else if($form->supportcourses == 'internal') {
@@ -228,7 +228,7 @@ function validate_form($form, &$err) {
if (isset($form->update_courses_id)) {
foreach ($form->update_courses_id as $course_id) {
$course = $form->{'course_' . $course_id};
- if (!empty($course[1]) && !empty($course[2])) {
+ if (!empty($course[1]) && !empty($course[2])) {
$lms_course_form_id[$course_id] = $course[0];
$saml_course_form_id[$course_id] = $course[1] . '_' . $course[2];
}
@@ -244,7 +244,7 @@ function validate_form($form, &$err) {
$lms_course_form_id[$i] = $new_course[0];
$saml_course_form_id[$i] = $new_course[1] . '_' . $new_course[2];
}
- }
+ }
}
//Comment the next line if you want let duplicate lms mapping
$err['course_mapping']['lms'] = array_diff_key($lms_course_form_id, array_unique($lms_course_form_id));
@@ -365,8 +365,8 @@ function process_config($config) {
if (!isset ($config->samllogoinfo)) {
$config->samllogoinfo = 'SAML login';
}
- if (!isset ($config->autologin)) {
- $config->autologin = false;
+ if (!isset ($config->autologin)) {
+ $config->autologin = false;
}
if (!isset ($config->samllogfile)) {
$config->samllogfile = '';
@@ -381,16 +381,16 @@ function process_config($config) {
$config->ignoreinactivecourses = '';
}
if (!isset ($config->externalcoursemappingdsn)) {
- $config->externalcoursemappingdsn = '';
+ $config->externalcoursemappingdsn = '';
}
if (!isset ($config->externalrolemappingdsn)) {
- $config->externalrolemappingdsn = '';
+ $config->externalrolemappingdsn = '';
}
if (!isset ($config->externalcoursemappingsql)) {
- $config->externalcoursemappingsql = '';
+ $config->externalcoursemappingsql = '';
}
if (!isset ($config->externalrolemappingsql)) {
- $config->externalrolemappingsql = '';
+ $config->externalrolemappingsql = '';
}
if (!isset ($config->disablejit)) {
$config->disablejit = false;
@@ -498,13 +498,13 @@ function process_config($config) {
}
}
}
- }
+ }
else {
//Updating roles
if (isset($config->update_roles_id) && empty($err['roles_mapping'])) {
foreach($config->update_roles_id as $role_id) {
$role = $config->{'role_' . $role_id};
- $sql = "UPDATE ".$DB->get_prefix() ."role_mapping SET lms_role='" . $role[0] . "', saml_role='" . $role[1] . "' where saml_role='" . $role_id . "'";
+ $sql = "UPDATE ".$DB->get_prefix() ."role_mapping SET lms_role='" . $role[0] . "', saml_role='" . $role[1] . "' where saml_role='" . $role_id . "'";
try {
$DB->execute($sql);
}
@@ -533,12 +533,27 @@ function process_config($config) {
if(isset($err['role_mapping_db']) || isset($err['course_mapping_db'])) {
return false;
}
-
+
//END-COURSE MAPPINGS
}
return true;
}
+ /**
+ * Get the auth description (from core or own auth lang files)
+ *
+ * @return string The description
+ */
+ function get_description() {
+ global $PAGE;
+ if ($PAGE->pagetype == 'admin-auth-saml') {
+ // Workaround require jquery and jquery-ui before auto_config.php $OUTPUT->header()
+ $PAGE->requires->jquery();
+ $PAGE->requires->jquery_plugin('ui');
+ }
+ return parent::get_description();
+ }
+
/**
* Cleans and returns first of potential many values (multi-valued attributes)
*
@@ -589,7 +604,7 @@ function create_role_mapping_db($DB, &$err) {
$dbman->create_table($table);
echo '';
print_string("auth_saml_sucess_creating_role_mapping", "auth_saml");
- echo '
';
+ echo '
';
}
catch (Exception $e) {
$err['role_mapping_db'][] = get_string("auth_saml_error_creating_role_mapping", "auth_saml");
@@ -599,7 +614,7 @@ function create_role_mapping_db($DB, &$err) {
function get_course_mapping_xmldb() {
- $table = new xmldb_table('course_mapping');
+ $table = new xmldb_table('course_mapping');
$table->add_field('course_mapping_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
$table->add_field('saml_course_id', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null);
@@ -647,5 +662,5 @@ function initialize_roles($DB, &$err) {
}
}
return $sucess;
- }
+ }
}
diff --git a/config.php b/config.php
index 18dad95..4d7daaa 100755
--- a/config.php
+++ b/config.php
@@ -1,14 +1,10 @@
+
-
-
-
-
-
ignoreinactivecourses)) {
$config->ignoreinactivecourses = true;
}
- if (!isset ($config->externalcoursemappingdsn)) {
- $config->externalcoursemappingdsn = '';
+ if (!isset ($config->externalcoursemappingdsn)) {
+ $config->externalcoursemappingdsn = '';
}
- if (!isset ($config->externalrolemappingdsn)) {
- $config->externalrolemappingdsn = '';
+ if (!isset ($config->externalrolemappingdsn)) {
+ $config->externalrolemappingdsn = '';
}
- if (!isset ($config->externalcoursemappingsql)) {
- $config->externalcoursemappingsql = '';
+ if (!isset ($config->externalcoursemappingsql)) {
+ $config->externalcoursemappingsql = '';
}
- if (!isset ($config->externalrolemappingsql)) {
- $config->externalrolemappingsql = '';
+ if (!isset ($config->externalrolemappingsql)) {
+ $config->externalrolemappingsql = '';
}
if (!isset ($config->disablejit)) {
@@ -342,7 +338,7 @@
DSN and SQL examples:
+DSN and SQL examples:
" . htmlspecialchars(get_string("auth_saml_mapping_dsn_examples", "auth_saml")) . ""; echo "" . htmlspecialchars(get_string("auth_saml_mapping_sql_examples", "auth_saml")) . "
"; diff --git a/login.php b/login.php index e017161..884a73f 100644 --- a/login.php +++ b/login.php @@ -2,7 +2,9 @@ include_once("../../config.php"); + global $CFG, $PAGE, $OUTPUT; +include_once($CFG->libdir . "/authlib.php"); //HTTPS is required in this page when $CFG->loginhttps enabled $PAGE->https_required(); @@ -21,6 +23,9 @@ exit; } +$errorcode = optional_param('errorcode', 0, PARAM_INT); + + $context = CONTEXT_SYSTEM::instance(); $PAGE->set_url("$CFG->httpswwwroot/auth/saml/login.php"); $PAGE->set_context($context); @@ -72,6 +77,22 @@ $frm = data_submitted(); +if (empty($errormsg) && $errorcode == AUTH_LOGIN_UNAUTHORISED) { + $errormsg = get_string("unauthorisedlogin", "", $frm->username); +} else if(empty($errormsg) && $errorcode == AUTH_LOGIN_FAILED) { + $errormsg = get_string("invalidlogin"); +} else if (empty($errormsg) && $errorcode == AUTH_LOGIN_LOCKOUT) { + $errormsg = get_string('sessionerroruser', 'error'); +} else if (empty($errormsg) && !empty($SESSION->loginerrormsg)) { + // We had some errors before redirect, show them now. + $errormsg = $SESSION->loginerrormsg; + unset($SESSION->loginerrormsg); +} + +if (!empty($errormsg) && method_exists($PAGE->requires, 'js_init_call')) { + $PAGE->requires->js_init_call('M.util.focus_login_error', null, true); +} + echo '