From 858fd4124864ca310d86cbfaabb6106554c5a975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Zi=C3=B3=C5=82ek?= Date: Fri, 20 Oct 2017 12:04:23 +0200 Subject: [PATCH] MDL-51892 logging: Proper description of login errors. --- lib/classes/event/user_login_failed.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/classes/event/user_login_failed.php b/lib/classes/event/user_login_failed.php index 1214b49df04..98e7aa36064 100644 --- a/lib/classes/event/user_login_failed.php +++ b/lib/classes/event/user_login_failed.php @@ -70,7 +70,23 @@ class user_login_failed extends base { public function get_description() { // Note that username could be any random user input. $username = s($this->other['username']); - return "Login failed for the username '{$username}' for the reason with id '{$this->other['reason']}'."; + $reasonid = $this->other['reason']; + $loginfailed = 'Login failed for user'; + switch ($reasonid){ + case 1: + return $loginfailed." '{$username}'. User does not exist (error ID '{$reasonid}')."; + case 2: + return $loginfailed." '{$username}'. User is suspended (error ID '{$reasonid}')."; + case 3: + return $loginfailed." '{$username}'. Most likely the password did not match (error ID '{$reasonid}')."; + case 4: + return $loginfailed." '{$username}'. User is locked out (error ID '{$reasonid}')."; + case 5: + return $loginfailed." '{$username}'. User is not authorised (error ID '{$reasonid}')."; + default: + return $loginfailed." '{$username}', error ID '{$reasonid}'."; + + } } /**