diff --git a/backend/Database.php b/backend/Database.php index 2f11edbeebb60a01be69e5d1cc0b71e1f5bdbb7b..61857ed946e0723c1e9f199873b53736a7172c71 100644 --- a/backend/Database.php +++ b/backend/Database.php @@ -137,20 +137,26 @@ class Backend { } public function authenticate(string $username, string $password) : bool { - if (!isset($username) || !isset($password)) + if (!isset($username) || !isset($password)) { + syslog(LOG_ERR, "Username or password not set"); return false; + } $this->findUser->bindParam(":username", $username); $this->findUser->execute(); $result = $this->findUser->fetch(\PDO::FETCH_ASSOC); - if ($result === FALSE) + if ($result === FALSE) { + syslog(LOG_ERR, "Couldn’t find user " . $username); return false; + } $user = new User($result); - if (!AuthHelper::initialAuthenticateUser($password, $user->password, $user->hashversion)) + if (!AuthHelper::initialAuthenticateUser($password, $user->password, $user->hashversion)) { + syslog(LOG_ERR, "Password does not match for user ".$username); return false; + } $this->user = $user; return true; diff --git a/login.php b/login.php index 9fa8e2a15d90fe0da551114fca13393cc5138cb8..1aa44fd59b5557e8c208fcb14b99979dc971d29e 100644 --- a/login.php +++ b/login.php @@ -19,6 +19,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['action']) && $_GET['ac $session->username = $username; $session->password = $password; $renderer->redirect('/'); + } else { + syslog(LOG_ERR, "Could not authenticate user " . $username); } } elseif (isset($_GET['action']) && $_GET['action'] === 'logout') { $session->destroy();