summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-09-02 11:45:28 +0200
committerAleksander Machniak <alec@alec.pl>2013-09-02 11:45:28 +0200
commit060467df9d95be3768dab51ff5dd4e6214ec86a0 (patch)
tree9a9249fa5860953b0284b8e32330558598fa407c /program
parent5a8ee396a15085941257d66751164d0fa5027843 (diff)
Log also failed logins to userlogins log
Diffstat (limited to 'program')
-rw-r--r--program/include/rcmail.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 62f6b6c46..1c9f3dd9c 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -954,22 +954,32 @@ class rcmail extends rcube
/**
* Write login data (name, ID, IP address) to the 'userlogins' log file.
*/
- public function log_login()
+ public function log_login($user, $failed_login = false, $error_code = 0)
{
if (!$this->config->get('log_logins')) {
return;
}
- $user_name = $this->get_user_name();
- $user_id = $this->get_user_id();
+ // failed login
+ if ($failed_login) {
+ $message = sprintf('Failed login for %s from %s in session %s (error: %d)',
+ $user, rcube_utils::remote_ip(), session_id(), $error_code);
+ }
+ // successful login
+ else {
+ $user_name = $this->get_user_name();
+ $user_id = $this->get_user_id();
- if (!$user_id) {
- return;
+ if (!$user_id) {
+ return;
+ }
+
+ $message = sprintf('Successful login for %s (ID: %d) from %s in session %s',
+ $user_name, $user_id, rcube_utils::remote_ip(), session_id());
}
- self::write_log('userlogins',
- sprintf('Successful login for %s (ID: %d) from %s in session %s',
- $user_name, $user_id, rcube_utils::remote_ip(), session_id()));
+ // log login
+ self::write_log('userlogins', $message);
}