Merge branch '3.8'

Conflicts:
	lib/Alchemy/Phrasea/Security/Firewall.php
This commit is contained in:
Nicolas Le Goff
2014-02-04 11:30:23 +01:00
7 changed files with 54 additions and 26 deletions

View File

@@ -102,7 +102,9 @@ class Login implements ControllerProviderInterface
// Displays the homepage // Displays the homepage
$controllers->get('/', 'login.controller:login') $controllers->get('/', 'login.controller:login')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
if (null !== $request->query->get('postlog')) { if (null !== $request->query->get('postlog')) {
@@ -127,14 +129,18 @@ class Login implements ControllerProviderInterface
// Authentication end point // Authentication end point
$controllers->post('/authenticate/', 'login.controller:authenticate') $controllers->post('/authenticate/', 'login.controller:authenticate')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
}) })
->bind('login_authenticate'); ->bind('login_authenticate');
// Guest access end point // Guest access end point
$controllers->match('/authenticate/guest/', 'login.controller:authenticateAsGuest') $controllers->match('/authenticate/guest/', 'login.controller:authenticateAsGuest')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
}) })
->bind('login_authenticate_as_guest') ->bind('login_authenticate_as_guest')
->method('GET|POST'); ->method('GET|POST');
@@ -142,14 +148,18 @@ class Login implements ControllerProviderInterface
// Authenticate with an AuthProvider // Authenticate with an AuthProvider
$controllers->get('/provider/{providerId}/authenticate/', 'login.controller:authenticateWithProvider') $controllers->get('/provider/{providerId}/authenticate/', 'login.controller:authenticateWithProvider')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
}) })
->bind('login_authentication_provider_authenticate'); ->bind('login_authentication_provider_authenticate');
// AuthProviders callbacks // AuthProviders callbacks
$controllers->get('/provider/{providerId}/callback/', 'login.controller:authenticationCallback') $controllers->get('/provider/{providerId}/callback/', 'login.controller:authenticationCallback')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
})->bind('login_authentication_provider_callback'); })->bind('login_authentication_provider_callback');
// Logout end point // Logout end point
@@ -161,13 +171,17 @@ class Login implements ControllerProviderInterface
// Registration end point ; redirects to classic registration or AuthProvider registration // Registration end point ; redirects to classic registration or AuthProvider registration
$controllers->get('/register/', 'login.controller:displayRegisterForm') $controllers->get('/register/', 'login.controller:displayRegisterForm')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
})->bind('login_register'); })->bind('login_register');
// Classic registration end point // Classic registration end point
$controllers->match('/register-classic/', 'login.controller:doRegistration') $controllers->match('/register-classic/', 'login.controller:doRegistration')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
}) })
->bind('login_register_classic'); ->bind('login_register_classic');
@@ -179,25 +193,33 @@ class Login implements ControllerProviderInterface
// Unlocks an email address that is currently locked // Unlocks an email address that is currently locked
$controllers->get('/register-confirm/', 'login.controller:registerConfirm') $controllers->get('/register-confirm/', 'login.controller:registerConfirm')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
})->bind('login_register_confirm'); })->bind('login_register_confirm');
// Displays a form to send an account unlock email again // Displays a form to send an account unlock email again
$controllers->get('/send-mail-confirm/', 'login.controller:sendConfirmMail') $controllers->get('/send-mail-confirm/', 'login.controller:sendConfirmMail')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
})->bind('login_send_mail'); })->bind('login_send_mail');
// Forgot password end point // Forgot password end point
$controllers->match('/forgot-password/', 'login.controller:forgotPassword') $controllers->match('/forgot-password/', 'login.controller:forgotPassword')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
})->bind('login_forgot_password'); })->bind('login_forgot_password');
// Renew password end point // Renew password end point
$controllers->match('/renew-password/', 'login.controller:renewPassword') $controllers->match('/renew-password/', 'login.controller:renewPassword')
->before(function (Request $request) use ($app) { ->before(function (Request $request) use ($app) {
$app['firewall']->requireNotAuthenticated(); if (null !== $response = $app['firewall']->requireNotAuthenticated()) {
return $response;
}
})->bind('login_renew_password'); })->bind('login_renew_password');
// Displays Terms of use // Displays Terms of use

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Security; namespace Alchemy\Phrasea\Security;
use Silex\Application; use Silex\Application;
use Symfony\Component\HttpFoundation\RedirectResponse;
class Firewall class Firewall
{ {
@@ -135,12 +136,8 @@ class Firewall
public function requireNotAuthenticated() public function requireNotAuthenticated()
{ {
if ($this->app['authentication']->isAuthenticated()) { if ($this->app['authentication']->isAuthenticated()) {
$this->app->abort(302, 'You are authenticated', [ return new RedirectResponse($this->app->path('prod'));
'X-Phraseanet-Redirect' => $this->app->path('prod')
]);
} }
return $this;
} }
public function requireOrdersAdmin() public function requireOrdersAdmin()

View File

@@ -431,7 +431,7 @@ class collection implements cache_cacheableInterface
$coll_id = phrasea::collFromBas($app, $base_id); $coll_id = phrasea::collFromBas($app, $base_id);
$sbas_id = phrasea::sbasFromBas($app, $base_id); $sbas_id = phrasea::sbasFromBas($app, $base_id);
if (! $sbas_id || ! $coll_id) { if (! $sbas_id || ! $coll_id) {
throw new Exception_Databox_CollectionNotFound(sprintf("Collection could not be found")); throw new Exception_Databox_CollectionNotFound(sprintf("Collection with base_id %s could not be found", $base_id));
} }
$databox = $app['phraseanet.appbox']->get_databox($sbas_id); $databox = $app['phraseanet.appbox']->get_databox($sbas_id);

View File

@@ -3,12 +3,12 @@
{% extends 'prod/Tooltip/Tooltip.html.twig' %} {% extends 'prod/Tooltip/Tooltip.html.twig' %}
{% set title %} {{ basket.getName() }} {% endset %} {% set title %} {{ basket.getName() }} {% endset %}
{% set width = 300 %} {% set width = 500 %}
{% set maxwidth = null %} {% set maxwidth = null %}
{% block content %} {% block content %}
<div class="noToolTipResize" style="margin:5px;width:{{ width - 40 }}px;height:300px;position:relative;"> <div class="noToolTipResize" style="margin:5px;width:{{ width - 40 }}px;height:auto !important;height:380px;max-height:380px;min-height:220px;position:relative;">
<div style="margin:5px 0"> <div style="margin:5px 0;max-height:160px;overflow:hidden;text-overflow:ellipsis;">
{{ basket.getDescription()|nl2br }} {{ basket.getDescription()|nl2br }}
</div> </div>
<div style="margin:5px 0;text-align:right;font-style:italic;position:relative;"> <div style="margin:5px 0;text-align:right;font-style:italic;position:relative;">
@@ -17,9 +17,9 @@
{% trans with {'%nb_records%' : nb_records} %}%nb_records% records{% endtrans %} {% trans with {'%nb_records%' : nb_records} %}%nb_records% records{% endtrans %}
- {{ date }} - {{ date }}
<hr/> <hr/>
<div style="position:relative;float:left;width:270px;"> <div style="position:relative;float:left;width:470px;">
{% for element in basket.getElements() %} {% for element in basket.getElements() %}
{% if loop.index <= 9 %} {% if loop.index <= 10 %}
<div style="margin:5px;position:relative;float:left;width:80px;height:80px;overflow:hidden;"> <div style="margin:5px;position:relative;float:left;width:80px;height:80px;overflow:hidden;">
{{ thumbnail.format(element.getRecord(app).get_thumbnail(), 80, 80 , '', false, false) }} {{ thumbnail.format(element.getRecord(app).get_thumbnail(), 80, 80 , '', false, false) }}
</div> </div>

View File

@@ -76,6 +76,15 @@ class RemovePluginTest extends PluginCommandTestCase
$command = new RemovePlugin(); $command = new RemovePlugin();
$command->setContainer(self::$DI['cli']); $command->setContainer(self::$DI['cli']);
self::$DI['cli']['plugins.manager'] = $this->getMockBuilder('Alchemy\Phrasea\Plugin\PluginManager')
->disableOriginalConstructor()
->getMock();
self::$DI['cli']['plugins.manager']->expects($this->once())
->method('hasPlugin')
->with('test-plugin')
->will($this->returnValue(true));
$data = $this->addPluginData(); $data = $this->addPluginData();
self::$DI['cli']['filesystem'] = $this->createFilesystemMock(); self::$DI['cli']['filesystem'] = $this->createFilesystemMock();

View File

@@ -190,8 +190,8 @@
// Sprite icons path // Sprite icons path
// ------------------------- // -------------------------
@iconSpritePath: "../img/glyphicons-halflings.png"; @iconSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings.png";
@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png"; @iconWhiteSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings-white.png";
// Input placeholder text color // Input placeholder text color

View File

@@ -194,8 +194,8 @@
// Sprite icons path // Sprite icons path
// ------------------------- // -------------------------
@iconSpritePath: "../img/glyphicons-halflings.png"; @iconSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings.png";
@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png"; @iconWhiteSpritePath: "/skins/build/bootstrap/img/glyphicons-halflings-white.png";
// Input placeholder text color // Input placeholder text color