1
0
Fork 0

Password verification

merge-requests/2/head
JelmerHinssen 7 years ago
parent d500318a33
commit 99d6e19487

@ -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);
});
}

@ -29,6 +29,9 @@
body{
color: #ff6000;
}
.footer{
text-align: center;
}
</style>
<body>
<div class = "jumbotron">
@ -48,7 +51,7 @@
</form>
</div>
<footer class = "footer">
Alle rechten voorbehouden
&copy 2017 Alle rechten voorbehouden
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>