]> BookStack Code Mirror - bookstack/blobdiff - app/Actions/ActivityService.php
Merge branch 'auth' of git://github.com/benrubson/BookStack into benrubson-auth
[bookstack] / app / Actions / ActivityService.php
index 9b69cbb1747662240d4c4055f8647f58a17bdb9b..0e3ac78611fec3188801e81e75bc6f6231e935de 100644 (file)
@@ -159,4 +159,21 @@ class ActivityService
             session()->flash('success', $message);
         }
     }
+
+    /**
+     * Log failed accesses, for further processing by tools like Fail2Ban
+     *
+     * @param username
+     * @return void
+      */
+    public function logFailedAccess($username)
+    {
+        $log_msg = config('logging.failed_access_message');
+
+        if (!is_string($username) || !is_string($log_msg) || strlen($log_msg)<1)
+            return;
+
+        $log_msg = str_replace("%u", $username, $log_msg);
+        error_log($log_msg, 4);
+    }
 }