mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-19 16:03:14 +00:00
Merge pull request #916 from romainneutron/avoid-exception-driven-filters
[3.8] Avoid exception driven filters
This commit is contained in:
@@ -101,7 +101,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')) {
|
||||||
|
|
||||||
@@ -126,14 +128,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');
|
||||||
@@ -141,14 +147,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
|
||||||
@@ -160,13 +170,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');
|
||||||
|
|
||||||
@@ -178,25 +192,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
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
namespace Alchemy\Phrasea\Security;
|
namespace Alchemy\Phrasea\Security;
|
||||||
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
|
|
||||||
class Firewall
|
class Firewall
|
||||||
{
|
{
|
||||||
@@ -126,12 +127,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', array(
|
return new RedirectResponse($this->app->path('prod'));
|
||||||
'X-Phraseanet-Redirect' => $this->app->path('prod')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireOrdersAdmin()
|
public function requireOrdersAdmin()
|
||||||
|
Reference in New Issue
Block a user