2017-02-23 14:31:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Informatica Eindproject D4p
|
|
|
|
* 6in3, Stedelijk Gymnasium Nijmegen
|
|
|
|
* Docent: Hans de Wolf
|
|
|
|
*
|
|
|
|
* ==================
|
|
|
|
*
|
|
|
|
* Daniel Boutros,
|
|
|
|
* Christiaan Goossens,
|
|
|
|
* Jelmer Hinssen
|
|
|
|
*/
|
|
|
|
|
2017-02-23 14:35:10 +00:00
|
|
|
namespace Inforbank\Application;
|
2017-02-23 14:31:25 +00:00
|
|
|
|
|
|
|
use \Slim\App;
|
2017-03-26 14:07:10 +00:00
|
|
|
use Inforbank\Application\Helper\Redirect;
|
2017-02-23 14:31:25 +00:00
|
|
|
|
2017-03-14 11:01:41 +00:00
|
|
|
class Login
|
|
|
|
{
|
|
|
|
public function __construct(App $app)
|
|
|
|
{
|
2017-02-23 14:31:25 +00:00
|
|
|
$app->get('/login', function ($request, $response, $args) {
|
|
|
|
// Render index view
|
|
|
|
return $this->renderer->render($response, 'login.phtml', $args);
|
|
|
|
});
|
2017-03-26 14:07:10 +00:00
|
|
|
|
2017-03-14 11:01:41 +00:00
|
|
|
$app->post('/login', function ($request, $response, $args) {
|
2017-02-23 14:31:25 +00:00
|
|
|
// Render index view
|
2017-03-14 11:01:41 +00:00
|
|
|
$post = $request->getParsedBody();
|
|
|
|
|
|
|
|
try {
|
|
|
|
$resp = $this->auth->login($post['rekeningnr'], $post['pascode']);
|
|
|
|
|
|
|
|
if ($resp) {
|
2017-03-29 15:09:21 +00:00
|
|
|
return Redirect::create($request, $response, '/');
|
2017-03-14 11:01:41 +00:00
|
|
|
} else {
|
2017-03-29 15:09:21 +00:00
|
|
|
return Redirect::create($request, $response, '/login?error');
|
2017-03-14 11:01:41 +00:00
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
2017-03-29 15:09:21 +00:00
|
|
|
return Redirect::create($request, $response, '/login?error');
|
2017-03-14 11:01:41 +00:00
|
|
|
}
|
2017-03-26 14:07:10 +00:00
|
|
|
});
|
2017-03-14 11:01:41 +00:00
|
|
|
|
2017-03-26 14:07:10 +00:00
|
|
|
$app->get('/logout', function ($request, $response, $args) {
|
|
|
|
$this->auth->logout();
|
2017-03-29 15:09:21 +00:00
|
|
|
return Redirect::create($request, $response, '/login');
|
2017-02-23 14:31:25 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|