1
0

Added static object linking & authorization methods

This commit is contained in:
2017-03-14 12:01:41 +01:00
parent 471b1cd75c
commit 1c54254c74
9 changed files with 242 additions and 36 deletions

View File

@ -16,32 +16,31 @@ namespace Inforbank\Application;
use \Slim\App;
class Login {
public function __construct(App $app) {
class Login
{
public function __construct(App $app)
{
$app->get('/login', function ($request, $response, $args) {
// Render index view
return $this->renderer->render($response, 'login.phtml', $args);
});
$app->post('/login', function ($request, $response, $args) {
$app->post('/login', function ($request, $response, $args) {
// Render index view
$post = $request->getParsedBody();
$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', '');
return $this->renderer->render($newResponse, 'login.phtml', $args);
$post = $request->getParsedBody();
try {
$resp = $this->auth->login($post['rekeningnr'], $post['pascode']);
if ($resp) {
echo "HIER EEN REDIRECT GRAAG";
} else {
echo "ERR PASS!";
}
} catch (\Exception $e) {
echo "ERR REK!";
}
die();
});
}
}