diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index 2a351f8b84..138ab823e7 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -213,15 +213,20 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $url = $app->url('lightbox_compare', array( + $arguments = array( 'ssel_id' => $Basket->getId(), - 'LOG' => $app['tokens']->getUrlToken( + ); + + if (!$app['phraseanet.registry']->get('GV_force_push_authentication') || !$request->get('force_authentication')) { + $arguments['LOG'] = $app['tokens']->getUrlToken( \random::TYPE_VIEW, $user_receiver->get_id(), null, $Basket->getId() - ) - )); + ); + } + + $url = $app->url('lightbox_compare', $arguments); $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : ''; @@ -359,7 +364,7 @@ class Push implements ControllerProviderInterface try { $participant_user = \User_Adapter::getInstance($participant['usr_id'], $app); } catch (\Exception $e) { - throw new ControllerException(sprintf(_('Unknown user %d'), $receiver['usr_id'])); + throw new ControllerException(sprintf(_('Unknown user %d'), $participant['usr_id'])); } try { diff --git a/lib/Alchemy/Phrasea/Security/Firewall.php b/lib/Alchemy/Phrasea/Security/Firewall.php index 66343cd9a6..4a31fe605e 100644 --- a/lib/Alchemy/Phrasea/Security/Firewall.php +++ b/lib/Alchemy/Phrasea/Security/Firewall.php @@ -102,10 +102,14 @@ class Firewall return $this; } - public function requireAuthentication() + public function requireAuthentication(Request $request = null) { + $params = array(); + if (null !== $request) { + $params['redirect'] = '..' . $request->getPathInfo(); + } if (!$this->app['authentication']->isAuthenticated()) { - return new RedirectResponse($this->app->path('homepage')); + return new RedirectResponse($this->app->path('homepage', $params)); } } @@ -118,7 +122,7 @@ class Firewall $app = $this->app; $controllers->before(function (Request $request) use ($app) { - if (null !== $response = $app['firewall']->requireAuthentication()) { + if (null !== $response = $app['firewall']->requireAuthentication($request)) { return $response; } }); diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 33f2aa9e87..d054ac6eda 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -265,6 +265,13 @@ return call_user_func_array(function(Application $app) { ), array( 'section' => _('Main configuration'), 'vars' => array( + array( + 'type' => \registry::TYPE_BOOLEAN, + 'name' => 'GV_force_push_authentication', + 'comment' => _('Enable Forcing authentication to see push content'), + 'help' => _('Adds an option to the push form submission to restrict push recipient(s) to Phraseanet users only.'), + 'default' => false + ), array( 'type' => \registry::TYPE_STRING, 'name' => 'GV_adminMail', diff --git a/templates/web/prod/actions/Push.html.twig b/templates/web/prod/actions/Push.html.twig index 52eb1f4ee1..0b68e6c352 100644 --- a/templates/web/prod/actions/Push.html.twig +++ b/templates/web/prod/actions/Push.html.twig @@ -214,6 +214,7 @@ +