Added static object linking & authorization methods
This commit is contained in:
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user