Commit 25edbfbf authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1592559: Allow the login errors to appear above in login box."

parents aef0cba9 b05bf1b9
......@@ -1440,6 +1440,21 @@ class AuthFactory {
}
}
/**
* Called when the login form is being validated during submission.
* Checks the user and password fields are filled in.
*
* @param object $form The Pieform form object
* @param array $values The submitted values
*/
function login_validate(Pieform $form, $values) {
if (!empty('login_submitted')) {
if (empty($values['login_username']) || empty($values['login_password'])) {
$form->set_error(null, get_string('loginfailed'));
}
}
}
/**
* Called when the login form is submitted. Validates the user and password, and
* if they are valid, starts a new session for the user.
......
......@@ -588,7 +588,13 @@ class Pieform {/*{{{*/
}
else {
global $SESSION;
$SESSION->add_error_msg($this->get_property('errormessage'));
// The login system comes past here twice so we need to pace first error message above form
if (!empty($values['login_submitted'])) {
$SESSION->add_error_msg($this->get_property('errormessage'), false, 'loginbox');
}
else {
$SESSION->add_error_msg($this->get_property('errormessage'));
}
}
}
}/*}}}*/
......@@ -684,7 +690,7 @@ class Pieform {/*{{{*/
}
$result .= '>';
if (!empty($this->error)) {
$result .= '<div class="error">' . $this->error . '</div>';
$result .= '<div class="alert alert-danger">' . $this->error . '</div>';
}
return $result;
}/*}}}*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment