You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Informatica Eindproject D4p
|
|
* 6in3, Stedelijk Gymnasium Nijmegen
|
|
* Docent: Hans de Wolf
|
|
*
|
|
* ==================
|
|
*
|
|
* Daniel Boutros,
|
|
* Christiaan Goossens,
|
|
* Jelmer Hinssen
|
|
*/
|
|
|
|
namespace Inforbank\Application;
|
|
|
|
use \Slim\App;
|
|
use Inforbank\Application\Helper\Redirect;
|
|
|
|
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) {
|
|
// Render index view
|
|
$post = $request->getParsedBody();
|
|
|
|
try {
|
|
$resp = $this->auth->login($post['rekeningnr'], $post['pascode']);
|
|
|
|
if ($resp) {
|
|
return Redirect::create($request, $response, '/');
|
|
} else {
|
|
return Redirect::create($request, $response, '/login?error');
|
|
}
|
|
} catch (\Exception $e) {
|
|
return Redirect::create($request, $response, '/login?error');
|
|
}
|
|
});
|
|
|
|
$app->get('/logout', function ($request, $response, $args) {
|
|
$this->auth->logout();
|
|
return Redirect::create($request, $response, '/login');
|
|
});
|
|
}
|
|
}
|