From 0805750c33368bb67389d08a0f85d0bd5d00420d Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 2 Apr 2021 10:07:45 +0200 Subject: [PATCH] redirect sur group d'invitation (ref #231) --- .../Controller/RegistrationController.php | 24 ++++++++++++++++--- .../views/Registration/info.html.twig | 5 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php index 31749669..1a9eed00 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php @@ -212,7 +212,7 @@ class RegistrationController extends Controller // Sur erreur $this->getErrorForm(null,$form,$request,$data,"submit",$idstatut); - // Sur validation(z) + // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { $data = $form->getData(); @@ -342,6 +342,8 @@ class RegistrationController extends Controller // A voir retour sur un écran d'info indiquant si validation par admion ou s'il doit matter ses email $this->get('session')->set('registrationinfo', $info); $this->get('session')->set('registrationmode', "info"); + $this->get('session')->set('registrationredirectto', null); + return $this->redirectToRoute('cadoles_core_registration_info'); } else { @@ -360,12 +362,16 @@ class RegistrationController extends Controller { $info = $this->get('session')->get('registrationinfo'); $mode = $this->get('session')->get('registrationmode'); + $redirectto = $this->get('session')->get('registrationredirectto'); + + return $this->render($this->labelentity.':info.html.twig', [ 'useheader' => true, 'usemenu' => false, 'usesidebar' => false, 'info' => $info, - 'mode' => $mode + 'mode' => $mode, + 'redirectto' => $redirectto, ]); } @@ -467,6 +473,7 @@ class RegistrationController extends Controller { $moderegistration = $this->getParameter('moderegistration'); $masteridentity = $this->getParameter('masteridentity'); + if($moderegistration=="none"||$masteridentity!="SQL") throw $this->createNotFoundException('Permission denied'); @@ -488,7 +495,8 @@ class RegistrationController extends Controller $mode="danger"; $this->get('session')->set('registrationinfo', $info); - $this->get('session')->set('registrationmode', $mode); + $this->get('session')->set('registrationmode', $mode); + $this->get('session')->set('registrationredirectto', null); } else { $url=$this->getUrlLogin(); @@ -539,10 +547,17 @@ class RegistrationController extends Controller // Si invitation à un groupe : on le rattache directement à ce groupe $groupid=$data[0]->getGroupid(); + $userid=$user->getId(); if($groupid) { $group=$em->getRepository("CadolesCoreBundle:Group")->find($groupid); if($group) { + $idpage =$group->getPages()->first()->getId(); + $url = $this->generateUrl('cadoles_core_redirect', ["route"=>"cadoles_core_home","id"=>$idpage], UrlGeneratorInterface::ABSOLUTE_URL); + $info="

Votre compte est à présent activé

Vous allez être redirigé vers la mire de connexion puis vers votre groupe de travail

Connexion"; + $this->get('session')->set('registrationinfo', $info); + $this->get('session')->set('registrationredirectto', $url); + $key = Uuid::uuid4(); $usergroup=new UserGroup(); $user=$em->getRepository("CadolesCoreBundle:User")->find($userid); @@ -688,6 +703,7 @@ class RegistrationController extends Controller $mode="info"; $this->get('session')->set('registrationinfo', $info); $this->get('session')->set('registrationmode', $mode); + $this->get('session')->set('registrationredirectto', null); return $this->redirectToRoute('cadoles_core_registration_info'); } @@ -724,6 +740,7 @@ class RegistrationController extends Controller $mode="danger"; $this->get('session')->set('registrationinfo', $info); $this->get('session')->set('registrationmode', $mode); + $this->get('session')->set('registrationredirectto', null); return $this->redirectToRoute('cadoles_core_registration_info'); } else { @@ -783,6 +800,7 @@ class RegistrationController extends Controller $mode="success"; $this->get('session')->set('registrationinfo', $info); $this->get('session')->set('registrationmode', $mode); + $this->get('session')->set('registrationredirectto', null); return $this->redirectToRoute('cadoles_core_registration_info'); } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/info.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/info.html.twig index 8343a917..ec8cd65c 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/info.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/info.html.twig @@ -18,7 +18,9 @@ $(document).ready(function() { // Redirection vers la mire d'authentification setTimeout(function(){ - {% if mode_auth == "SAML" %} + {% if redirectto is defined and redirectto is not null %} + window.location.href="{{ redirectto }}"; + {% elseif mode_auth == "SAML" %} window.location.href="{{ path("lightsaml_sp.login") }}"; {% elseif mode_auth == "CAS" %} window.location.href="{{ path("cas_sp.login") }}"; @@ -32,6 +34,5 @@ }, 6000); }); {% endif %} - {% endblock %}