From 7c469c62c0db28a67d0552d08a7316291bb2b94e Mon Sep 17 00:00:00 2001 From: Jouni Suorsa Date: Fri, 16 Sep 2016 10:25:45 +0300 Subject: [PATCH] Added some errorcode param handling to login.php. --- login.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/login.php b/login.php index e017161..7019908 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 ($errorcode == AUTH_LOGIN_UNAUTHORISED) { + $errormsg = get_string("unauthorisedlogin", "", $frm->username); +} else if($errorcode == AUTH_LOGIN_FAILED) { + $errormsg = get_string("invalidlogin"); +} else if ($errorcode == AUTH_LOGIN_LOCKOUT) { + $errormsg = get_string('sessionerroruser', 'error'); +} else if (!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 '
'; if (in_array('saml', $authsequence)){