1
0

Password verification

This commit is contained in:
JelmerHinssen
2017-03-08 16:45:26 +01:00
parent d500318a33
commit 99d6e19487
2 changed files with 19 additions and 4 deletions

View File

@ -24,11 +24,23 @@ class Login {
});
$app->post('/login', function ($request, $response, $args) {
// Render index view
$post = $request->getParsedBody();
if(isset($_POST["username"])){
echo "Jouw naam is: " . $_POST["username"] . " en je wachtwoord is: " . $_POST["password"] . "<br/>\n";
$user = $this->db->gebruikers("username = ?", $post["username"]);
if ($user->count("*") === 0){
echo "Onjuiste gebruikersnaam of wachtwoord";
} else {
if(password_verify($post["password"], $user["password"])){
session_start();
$_SESSION["user"] = [
"uuid" => $user["uuid"],
"username" => $user["username"]
];
}else{
echo "fout";
}
}
$newResponse = $response->withHeader('Location', 'index.php');
$newResponse = $response->withHeader('Location', '');
return $this->renderer->render($newResponse, 'login.phtml', $args);
});
}