Logout in case the session is not found

This commit is contained in:
Romain Neutron
2013-01-29 16:26:21 +01:00
parent b2285f0b3f
commit 774f6d541b
6 changed files with 66 additions and 9 deletions

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Alchemy\Phrasea\Controller\Exception as ControllerException;
use Silex\ControllerProviderInterface;
use Silex\Application as SilexApplication;
@@ -60,7 +61,11 @@ class Lightbox implements ControllerProviderInterface
});
$controllers->get('/', function (SilexApplication $app) {
try {
\User_Adapter::updateClientInfos($app, 6);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$repository = $app['EM']->getRepository('\Entities\Basket');
@@ -184,7 +189,11 @@ class Lightbox implements ControllerProviderInterface
$controllers->get('/validate/{ssel_id}/', function (SilexApplication $app, $ssel_id) {
try {
\User_Adapter::updateClientInfos($app, 6);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$repository = $app['EM']->getRepository('\Entities\Basket');
@@ -232,7 +241,11 @@ class Lightbox implements ControllerProviderInterface
$controllers->get('/compare/{ssel_id}/', function (SilexApplication $app, $ssel_id) {
try {
\User_Adapter::updateClientInfos($app, 6);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$repository = $app['EM']->getRepository('\Entities\Basket');
@@ -282,7 +295,11 @@ class Lightbox implements ControllerProviderInterface
$controllers->get('/feeds/entry/{entry_id}/', function (SilexApplication $app, $entry_id) {
try {
\User_Adapter::updateClientInfos($app, 6);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$feed_entry = \Feed_Entry_Adapter::load_from_id($app, $entry_id);

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -32,7 +33,11 @@ class Root implements ControllerProviderInterface
});
$controllers->get('/', function(Application $app, Request $request) {
try {
\User_Adapter::updateClientInfos($app, 3);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$section = $request->query->get('section', false);
@@ -96,7 +101,11 @@ class Root implements ControllerProviderInterface
})->bind('admin');
$controllers->get('/tree/', function(Application $app, Request $request) {
try {
\User_Adapter::updateClientInfos($app, 3);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$section = $request->query->get('section', false);

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Controller\Client;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\Finder\Finder;
@@ -285,7 +286,11 @@ class Root implements ControllerProviderInterface
*/
public function getClient(Application $app, Request $request)
{
try {
\User_Adapter::updateClientInfos($app, 2);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$renderTopics = '';
if ($app['phraseanet.registry']->get('GV_client_render_topics') == 'popups') {

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Silex\Application as SilexApplication;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -43,8 +44,11 @@ class Root implements ControllerProviderInterface
});
$controllers->get('/', function(Application $app) {
try {
\User_Adapter::updateClientInfos($app, 1);
} catch (SessionNotFound $e) {
return $app->redirect($app['url_generator']->generate('logout'));
}
$cssPath = $app['phraseanet.registry']->get('GV_RootPath') . 'www/skins/prod/';

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Exception;
class SessionNotFound extends RuntimeException
{
}

View File

@@ -11,6 +11,8 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\SessionNotFound;
/**
*
* @package User
@@ -1461,6 +1463,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$session = $app['EM']->find('Entities\Session', $app['session']->get('session_id'));
if (!$session) {
throw new SessionNotFound('No session found');
}
if (!$session->hasModuleId($app_id)) {
$module = new \Entities\SessionModule();