Files
Phraseanet/lib/Alchemy/Phrasea/Security/Firewall.php
Nicolas Le Goff 623469063f refactor /prod/order/
add tests

fix tests

use url_generator & remove debug variable

remove jquery.order.js from  minify

use proper way to pass parameters when building URL with url_generator
2012-09-07 12:06:05 +02:00

57 lines
1.3 KiB
PHP

<?php
namespace Alchemy\Phrasea\Security;
use Silex\Application;
class Firewall
{
public function requireSetUp(Application $app)
{
if ( ! \setup::is_installed()) {
return $app->redirect("/setup/");
}
}
public function requireAdmin(Application $app)
{
if (null !== $response = $this->requireAuthentication($app)) {
return $response;
}
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->is_admin()) {
$app->abort(403);
}
}
public function requireAuthentication(Application $app)
{
if (false === $app['phraseanet.core']->isAuthenticated()) {
return $app->redirect('/login/');
}
if ($app['phraseanet.core']->getAuthenticatedUser()->is_guest()) {
return $app->redirect('/login/');
}
try {
$session = $app['phraseanet.appbox']->get_session();
$session->open_phrasea_session();
} catch (\Exception $e) {
return $app->redirect('/login/logout/');
}
}
public function requireOrdersAdmin(Application $app) {
if ( false === ! ! count($app['phraseanet.core']->getAuthenticatedUser()->ACL()->get_granted_base(array('order_master')))) {
$app->abort(403);
}
}
}