Password verification
This commit is contained in:
parent
d500318a33
commit
99d6e19487
@ -24,11 +24,23 @@ class Login {
|
|||||||
});
|
});
|
||||||
$app->post('/login', function ($request, $response, $args) {
|
$app->post('/login', function ($request, $response, $args) {
|
||||||
// Render index view
|
// Render index view
|
||||||
|
$post = $request->getParsedBody();
|
||||||
|
|
||||||
if(isset($_POST["username"])){
|
$user = $this->db->gebruikers("username = ?", $post["username"]);
|
||||||
echo "Jouw naam is: " . $_POST["username"] . " en je wachtwoord is: " . $_POST["password"] . "<br/>\n";
|
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);
|
return $this->renderer->render($newResponse, 'login.phtml', $args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
body{
|
body{
|
||||||
color: #ff6000;
|
color: #ff6000;
|
||||||
}
|
}
|
||||||
|
.footer{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<div class = "jumbotron">
|
<div class = "jumbotron">
|
||||||
@ -48,7 +51,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<footer class = "footer">
|
<footer class = "footer">
|
||||||
Alle rechten voorbehouden
|
© 2017 Alle rechten voorbehouden
|
||||||
</footer>
|
</footer>
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
<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>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||||
|
Reference in New Issue
Block a user