Skip to content
Snippets Groups Projects
Commit ee9f1363 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Added error messages

parent 832b77f9
No related branches found
No related tags found
No related merge requests found
...@@ -137,20 +137,26 @@ class Backend { ...@@ -137,20 +137,26 @@ class Backend {
} }
public function authenticate(string $username, string $password) : bool { 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; return false;
}
$this->findUser->bindParam(":username", $username); $this->findUser->bindParam(":username", $username);
$this->findUser->execute(); $this->findUser->execute();
$result = $this->findUser->fetch(\PDO::FETCH_ASSOC); $result = $this->findUser->fetch(\PDO::FETCH_ASSOC);
if ($result === FALSE) if ($result === FALSE) {
syslog(LOG_ERR, "Couldn’t find user " . $username);
return false; return false;
}
$user = new User($result); $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; return false;
}
$this->user = $user; $this->user = $user;
return true; return true;
......
...@@ -19,6 +19,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['action']) && $_GET['ac ...@@ -19,6 +19,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['action']) && $_GET['ac
$session->username = $username; $session->username = $username;
$session->password = $password; $session->password = $password;
$renderer->redirect('/'); $renderer->redirect('/');
} else {
syslog(LOG_ERR, "Could not authenticate user " . $username);
} }
} elseif (isset($_GET['action']) && $_GET['action'] === 'logout') { } elseif (isset($_GET['action']) && $_GET['action'] === 'logout') {
$session->destroy(); $session->destroy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment