Commit 8fef3553 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1897484: Showing a different generic message when failing to login



As the normal one relates to form fields and that is not always correct

Change-Id: Id4f061a082366deaf3aa5caafd0058b622af25e4
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 89eb1401
......@@ -2008,6 +2008,15 @@ function login_validate(Pieform $form, $values) {
}
}
/**
* Called when the login form fails.
*
* @param object $form The Pieform form object
*/
function login_error(Pieform $form) {
$form->set_property('errormessage', get_string('errorunabletologin', 'auth'));
}
/**
* Called when the login form is submitted. Validates the user and password, and
* if they are valid, starts a new session for the user.
......@@ -2157,7 +2166,9 @@ function login_submit(Pieform $form, $values) {
return;
}
}
catch (AccessTotallyDeniedException $e) {
throw new AccessTotallyDeniedException($e->getMessage());
}
// Do redirect on login to avoid browser back button exploit
// We need to strip the path from domain set in $wwwroot from the path we are trying
// to get to.
......
......@@ -45,7 +45,7 @@ $string['application'] = 'Application';
$string['cantretrievekey'] = 'An error occurred while retrieving the public key from the remote server.<br>Please ensure that the Application and WWW root fields are correct and that networking is enabled on the remote host.';
$string['ssodirection'] = 'SSO direction';
$string['active'] = 'Active';
$string['errorunabletologin'] = 'You are unable to login';
$string['errorcertificateinvalidwwwroot'] = 'This certificate claims to be for %s, but you are trying to use it for %s.';
$string['errorcouldnotgeneratenewsslkey'] = 'Could not generate a new SSL key. Are you sure that both openssl and the PHP module for openssl are installed on this machine?';
$string['errnoauthinstances'] = 'We do not seem to have any authentication plugin instances configured for the host at %s.';
......
......@@ -236,6 +236,10 @@ class Pieform {/*{{{*/
$this->data['replycallback'] = $this->name . '_reply';
}
if (!$this->data['errorcallback']) {
$this->data['errorcallback'] = $this->name . '_error';
}
$this->data['configdirs'] = array_map(
function($a) { return substr($a, -1) == "/" ? substr($a, 0, -1) : $a; },
(array) $this->data['configdirs']);
......
......@@ -16,7 +16,7 @@ Scenario: Too many bad password attempts
When I log in as "UserA" with password "wrongpassword"
# Check for error message for first attempt invalid login
Then I should see "You have not provided the correct credentials to log in. Please check your username and password are correct."
And I should see "There was an error with submitting this form. Please check the marked fields and try again."
And I should see "You are unable to login"
And I log in as "UserA" with password "wrongpassword"
And I log in as "UserA" with password "wrongpassword"
And I log in as "UserA" with password "wrongpassword"
......
Supports Markdown
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