mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Merge pull request #481 from romainneutron/fix-07-10-03
[3.8] Multiple fixes
This commit is contained in:
@@ -38,14 +38,6 @@ return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->before(function(Request $request) use ($app) {
|
|
||||||
if ($request->cookies->has('persistent') && !$app['authentication']->isAuthenticated()) {
|
|
||||||
if (false !== $session = $app['authentication.persistent-manager']->getSession($request->cookies->get('persistent'))) {
|
|
||||||
$app['authentication']->refreshAccount($session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$app->bindRoutes();
|
$app->bindRoutes();
|
||||||
|
|
||||||
if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) {
|
if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) {
|
||||||
|
@@ -1014,6 +1014,9 @@ class Login implements ControllerProviderInterface
|
|||||||
->setNonce($nonce);
|
->setNonce($nonce);
|
||||||
$cookie = new Cookie('persistent', $token);
|
$cookie = new Cookie('persistent', $token);
|
||||||
$response->headers->setCookie($cookie);
|
$response->headers->setCookie($cookie);
|
||||||
|
|
||||||
|
$app['EM']->persist($session);
|
||||||
|
$app['EM']->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = new PostAuthenticate($request, $response, $user, $context);
|
$event = new PostAuthenticate($request, $response, $user, $context);
|
||||||
|
@@ -0,0 +1,45 @@
|
|||||||
|
<?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\Core\Event\Subscriber;
|
||||||
|
|
||||||
|
use Silex\Application;
|
||||||
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
|
|
||||||
|
class PersistentCookieSubscriber implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
private $app;
|
||||||
|
|
||||||
|
public function __construct(Application $app)
|
||||||
|
{
|
||||||
|
$this->app = $app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
KernelEvents::REQUEST => array('checkPersistentCookie', 128),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPersistentCookie(GetResponseEvent $event)
|
||||||
|
{
|
||||||
|
$request = $event->getRequest();
|
||||||
|
|
||||||
|
if ($request->cookies->has('persistent') && !$this->app['authentication']->isAuthenticated()) {
|
||||||
|
if (false !== $session = $this->app['authentication.persistent-manager']->getSession($request->cookies->get('persistent'))) {
|
||||||
|
$this->app['authentication']->refreshAccount($session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -26,6 +26,7 @@ use Alchemy\Phrasea\Authentication\SuggestionFinder;
|
|||||||
use Alchemy\Phrasea\Authentication\Token\TokenValidator;
|
use Alchemy\Phrasea\Authentication\Token\TokenValidator;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\PersistentCookieSubscriber;
|
||||||
|
|
||||||
class AuthenticationManagerServiceProvider implements ServiceProviderInterface
|
class AuthenticationManagerServiceProvider implements ServiceProviderInterface
|
||||||
{
|
{
|
||||||
@@ -67,7 +68,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
}, $authConf['auto-create']['templates']));
|
}, $authConf['auto-create']['templates']));
|
||||||
|
|
||||||
$enabled = $app['phraseanet.registry']->get('GV_autoregister') && $app['registration.enabled'];
|
$enabled = $app['phraseanet.registry']->get('GV_autoregister') && $app['registration.enabled'];
|
||||||
|
|
||||||
return new AccountCreator($app['tokens'], $app['phraseanet.appbox'], $enabled, $templates);
|
return new AccountCreator($app['tokens'], $app['phraseanet.appbox'], $enabled, $templates);
|
||||||
@@ -126,5 +127,12 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
|
|||||||
|
|
||||||
public function boot(Application $app)
|
public function boot(Application $app)
|
||||||
{
|
{
|
||||||
|
$app['dispatcher'] = $app->share(
|
||||||
|
$app->extend('dispatcher', function($dispatcher, Application $app){
|
||||||
|
$dispatcher->addSubscriber(new PersistentCookieSubscriber($app));
|
||||||
|
|
||||||
|
return $dispatcher;
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,13 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
$app['debug']
|
$app['debug']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function boot(SilexApplication $app)
|
||||||
|
{
|
||||||
$app['dispatcher'] = $app->share(
|
$app['dispatcher'] = $app->share(
|
||||||
$app->extend('dispatcher', function($dispatcher, SilexApplication $app){
|
$app->extend('dispatcher', function($dispatcher, SilexApplication $app){
|
||||||
$dispatcher->addSubscriber(new TrustedProxySubscriber($app['phraseanet.configuration']));
|
$dispatcher->addSubscriber(new TrustedProxySubscriber($app['phraseanet.configuration']));
|
||||||
@@ -50,8 +56,4 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function boot(SilexApplication $app)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,13 @@ class FileServeServiceProvider implements ServiceProviderInterface
|
|||||||
$app['phraseanet.file-serve'] = $app->share(function (Application $app) {
|
$app['phraseanet.file-serve'] = $app->share(function (Application $app) {
|
||||||
return ServeFileResponseFactory::create($app);
|
return ServeFileResponseFactory::create($app);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function boot(Application $app)
|
||||||
|
{
|
||||||
$app['dispatcher'] = $app->share(
|
$app['dispatcher'] = $app->share(
|
||||||
$app->extend('dispatcher', function($dispatcher, Application $app){
|
$app->extend('dispatcher', function($dispatcher, Application $app){
|
||||||
$dispatcher->addSubscriber(new XSendFileSubscriber($app));
|
$dispatcher->addSubscriber(new XSendFileSubscriber($app));
|
||||||
@@ -40,11 +46,4 @@ class FileServeServiceProvider implements ServiceProviderInterface
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function boot(Application $app)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user