mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Add AuthenticationServiceProvider
This commit is contained in:
@@ -29,13 +29,13 @@ class Lightbox implements ControllerProviderInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if ($app->isAuthenticated()) {
|
||||
$app->closeAccount();
|
||||
if ($app['authentication']->isAuthenticated()) {
|
||||
$app['authentication']->closeAccount();
|
||||
}
|
||||
|
||||
try {
|
||||
$auth = new \Session_Authentication_Token($app, $request->query->get('LOG'));
|
||||
$app->openAccount($auth);
|
||||
$app['authentication']->openAccount($auth);
|
||||
} catch (Exception $e) {
|
||||
return $app->redirect("/login/?error=" . urlencode($e->getMessage()));
|
||||
}
|
||||
@@ -72,8 +72,8 @@ class Lightbox implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\BasketRepository */
|
||||
|
||||
$basket_collection = array_merge(
|
||||
$repository->findActiveByUser($app['phraseanet.user'])
|
||||
, $repository->findActiveValidationByUser($app['phraseanet.user'])
|
||||
$repository->findActiveByUser($app['authentication']->getUser())
|
||||
, $repository->findActiveValidationByUser($app['authentication']->getUser())
|
||||
);
|
||||
|
||||
$template = 'lightbox/index.html.twig';
|
||||
@@ -97,7 +97,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
|
||||
$basketElement = $app['EM']
|
||||
->getRepository('\Entities\BasketElement')
|
||||
->findUserElement($sselcont_id, $app['phraseanet.user']);
|
||||
->findUserElement($sselcont_id, $app['authentication']->getUser());
|
||||
|
||||
$parameters = array(
|
||||
'basket_element' => $basketElement,
|
||||
@@ -111,7 +111,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\BasketElementRepository */
|
||||
$repository = $app['EM']->getRepository('\Entities\BasketElement');
|
||||
|
||||
$BasketElement = $repository->findUserElement($sselcont_id, $app['phraseanet.user']);
|
||||
$BasketElement = $repository->findUserElement($sselcont_id, $app['authentication']->getUser());
|
||||
|
||||
if ($app['browser']->isMobile()) {
|
||||
$output = $app['twig']->render('lightbox/basket_element.html.twig', array(
|
||||
@@ -199,12 +199,12 @@ class Lightbox implements ControllerProviderInterface
|
||||
|
||||
/* @var $repository \Repositories\BasketRepository */
|
||||
$basket_collection = $repository->findActiveValidationAndBasketByUser(
|
||||
$app['phraseanet.user']
|
||||
$app['authentication']->getUser()
|
||||
);
|
||||
|
||||
$basket = $repository->findUserBasket(
|
||||
$app, $ssel_id
|
||||
, $app['phraseanet.user']
|
||||
, $app['authentication']->getUser()
|
||||
, false
|
||||
);
|
||||
|
||||
@@ -214,9 +214,9 @@ class Lightbox implements ControllerProviderInterface
|
||||
$app['EM']->flush();
|
||||
}
|
||||
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['phraseanet.user'], $app)->getIsAware() === false) {
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->getIsAware() === false) {
|
||||
$basket = $app['EM']->merge($basket);
|
||||
$basket->getValidation()->getParticipant($app['phraseanet.user'], $app)->setIsAware(true);
|
||||
$basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->setIsAware(true);
|
||||
$app['EM']->flush();
|
||||
}
|
||||
|
||||
@@ -251,12 +251,12 @@ class Lightbox implements ControllerProviderInterface
|
||||
|
||||
/* @var $repository \Repositories\BasketRepository */
|
||||
$basket_collection = $repository->findActiveValidationAndBasketByUser(
|
||||
$app['phraseanet.user']
|
||||
$app['authentication']->getUser()
|
||||
);
|
||||
|
||||
$basket = $repository->findUserBasket(
|
||||
$app, $ssel_id
|
||||
, $app['phraseanet.user']
|
||||
, $app['authentication']->getUser()
|
||||
, false
|
||||
);
|
||||
|
||||
@@ -266,9 +266,9 @@ class Lightbox implements ControllerProviderInterface
|
||||
$app['EM']->flush();
|
||||
}
|
||||
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['phraseanet.user'])->getIsAware() === false) {
|
||||
if ($basket->getValidation() && $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) {
|
||||
$basket = $app['EM']->merge($basket);
|
||||
$basket->getValidation()->getParticipant($app['phraseanet.user'], $app)->setIsAware(true);
|
||||
$basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->setIsAware(true);
|
||||
$app['EM']->flush();
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\BasketRepository */
|
||||
$basket = $repository->findUserBasket(
|
||||
$app, $ssel_id
|
||||
, $app['phraseanet.user']
|
||||
, $app['authentication']->getUser()
|
||||
, false
|
||||
);
|
||||
|
||||
@@ -357,9 +357,9 @@ class Lightbox implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\BasketElementRepository */
|
||||
$repository = $app['EM']->getRepository('\Entities\BasketElement');
|
||||
|
||||
$basket_element = $repository->findUserElement($sselcont_id, $app['phraseanet.user']);
|
||||
$basket_element = $repository->findUserElement($sselcont_id, $app['authentication']->getUser());
|
||||
|
||||
$validationDatas = $basket_element->getUserValidationDatas($app['phraseanet.user'], $app);
|
||||
$validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser(), $app);
|
||||
|
||||
$validationDatas->setNote($note);
|
||||
|
||||
@@ -405,14 +405,14 @@ class Lightbox implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\BasketElementRepository */
|
||||
$basket_element = $repository->findUserElement(
|
||||
$sselcont_id
|
||||
, $app['phraseanet.user']
|
||||
, $app['authentication']->getUser()
|
||||
);
|
||||
/* @var $basket_element \Entities\BasketElement */
|
||||
$validationDatas = $basket_element->getUserValidationDatas($app['phraseanet.user'], $app);
|
||||
$validationDatas = $basket_element->getUserValidationDatas($app['authentication']->getUser(), $app);
|
||||
|
||||
if (!$basket_element->getBasket()
|
||||
->getValidation()
|
||||
->getParticipant($app['phraseanet.user'], $app)->getCanAgree()) {
|
||||
->getParticipant($app['authentication']->getUser(), $app)->getCanAgree()) {
|
||||
throw new ControllerException('You can not agree on this');
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
|
||||
$participant = $basket_element->getBasket()
|
||||
->getValidation()
|
||||
->getParticipant($app['phraseanet.user'], $app);
|
||||
->getParticipant($app['authentication']->getUser(), $app);
|
||||
|
||||
$app['EM']->merge($basket_element);
|
||||
|
||||
@@ -453,7 +453,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\BasketRepository */
|
||||
$basket = $repository->findUserBasket(
|
||||
$app, $ssel_id
|
||||
, $app['phraseanet.user']
|
||||
, $app['authentication']->getUser()
|
||||
, false
|
||||
);
|
||||
|
||||
@@ -461,7 +461,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
throw new ControllerException('There is no validation session attached to this basket');
|
||||
}
|
||||
|
||||
if (!$basket->getValidation()->getParticipant($app['phraseanet.user'], $app)->getCanAgree()) {
|
||||
if (!$basket->getValidation()->getParticipant($app['authentication']->getUser(), $app)->getCanAgree()) {
|
||||
throw new ControllerException('You have not right to agree');
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
/* @var $basket \Entities\Basket */
|
||||
$participant = $basket->getValidation()->getParticipant($app['phraseanet.user'], $app);
|
||||
$participant = $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app);
|
||||
|
||||
$expires = new \DateTime('+10 days');
|
||||
$url = $app['phraseanet.registry']->get('GV_ServerName')
|
||||
@@ -492,7 +492,7 @@ class Lightbox implements ControllerProviderInterface
|
||||
$to = $basket->getValidation()->getInitiator($app)->get_id();
|
||||
$params = array(
|
||||
'ssel_id' => $basket->getId(),
|
||||
'from' => $app['phraseanet.user']->get_id(),
|
||||
'from' => $app['authentication']->getUser()->get_id(),
|
||||
'url' => $url,
|
||||
'to' => $to
|
||||
);
|
||||
|
Reference in New Issue
Block a user