1
0

Add redirects to the login page

This commit is contained in:
Christiaan Goossens 2017-03-31 19:10:28 +02:00
parent 5d998b0e33
commit 40b7b321ec
2 changed files with 11 additions and 6 deletions

View File

@ -36,17 +36,21 @@ 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(); $post = $request->getParsedBody();
$query = $request->getQueryParams();
$redirect = $query['redirect'];
try { try {
$resp = $this->auth->login($post['rekeningnr'], $post['pascode']); $resp = $this->auth->login($post['rekeningnr'], $post['pascode']);
if ($resp) { if ($resp && $redirect !== "") {
return Redirect::create($request, $response, '/'); return Redirect::create($request, $response, $redirect);
} elseif ($resp) {
return Redirect::create($request, $response, '/rekeningen');
} else { } else {
return Redirect::create($request, $response, '/login?error'); return Redirect::create($request, $response, '/login?error&redirect='.$redirect);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
return Redirect::create($request, $response, '/login?error'); return Redirect::create($request, $response, '/login?error&redirect='.$redirect);
} }
}); });

View File

@ -27,6 +27,7 @@
?> ?>
<div class="alert alert-warning" role="alert">De ingevulde gegevens zijn incorrect. Probeer het opnieuw.</div><br/> <div class="alert alert-warning" role="alert">De ingevulde gegevens zijn incorrect. Probeer het opnieuw.</div><br/>
<?php <?php
} ?> } ?>
<form method="post" action=""> <form method="post" action="">
<input type="text" name="rekeningnr" placeholder="Rekeningnummer (alleen cijfers)"> <input type="text" name="rekeningnr" placeholder="Rekeningnummer (alleen cijfers)">