mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Logout in case the session is not found
This commit is contained in:
@@ -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) {
|
||||
\User_Adapter::updateClientInfos($app, 6);
|
||||
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) {
|
||||
|
||||
\User_Adapter::updateClientInfos($app, 6);
|
||||
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) {
|
||||
|
||||
\User_Adapter::updateClientInfos($app, 6);
|
||||
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) {
|
||||
|
||||
\User_Adapter::updateClientInfos($app, 6);
|
||||
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);
|
||||
|
||||
|
@@ -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) {
|
||||
\User_Adapter::updateClientInfos($app, 3);
|
||||
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) {
|
||||
\User_Adapter::updateClientInfos($app, 3);
|
||||
try {
|
||||
\User_Adapter::updateClientInfos($app, 3);
|
||||
} catch (SessionNotFound $e) {
|
||||
return $app->redirect($app['url_generator']->generate('logout'));
|
||||
}
|
||||
|
||||
$section = $request->query->get('section', false);
|
||||
|
||||
|
@@ -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)
|
||||
{
|
||||
\User_Adapter::updateClientInfos($app, 2);
|
||||
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') {
|
||||
|
@@ -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) {
|
||||
|
||||
\User_Adapter::updateClientInfos($app, 1);
|
||||
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/';
|
||||
|
||||
|
16
lib/Alchemy/Phrasea/Exception/SessionNotFound.php
Normal file
16
lib/Alchemy/Phrasea/Exception/SessionNotFound.php
Normal 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
|
||||
{
|
||||
}
|
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user