Add tests to persistent cookie

This commit is contained in:
Romain Neutron
2012-10-04 16:29:38 +02:00
parent ebac1d1e39
commit e844de6a72
3 changed files with 97 additions and 12 deletions

View File

@@ -56,6 +56,7 @@ use Alchemy\Phrasea\Controller\Prod\WorkZone;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
use Silex\Application as SilexApp;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@@ -68,6 +69,17 @@ return call_user_func(function($environment = null) {
$app['firewall']->requireSetup($app);
});
$app->before(function(Request $request) use ($app) {
if (!$app->isAuthenticated() && $request->cookies->has('persistent')) {
try {
$auth = new \Session_Authentication_PersistentCookie($app, $request->cookies->get('persistent'));
$app->openAccount($auth, $auth->getSessionId());
} catch (\Exception $e) {
}
}
});
$app->get('/', function(SilexApp $app) {
if ($app['browser']->isMobile()) {
return $app->redirect("/login/?redirect=lightbox");