From 00a2a2a328f8cc5ef698e85c38e00dc7aacb166a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Sun, 13 Dec 2020 22:57:48 +0100 Subject: [PATCH] Remove blocking for guest Prevent having session= when id already in the route --- Controller/ApplicationController.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Controller/ApplicationController.php b/Controller/ApplicationController.php index 8a9a8b4..7cb9d97 100644 --- a/Controller/ApplicationController.php +++ b/Controller/ApplicationController.php @@ -72,15 +72,6 @@ class ApplicationController extends DefaultController { //Get data $data = $form->getData(); - //Count session at location in last month for guest - if (!$this->isGranted('ROLE_REGULAR') && !empty($session = $doctrine->getRepository(Session::class)->findOneWithinLastMonthByLocationUser($data['location']->getId(), $this->getUser()->getId()))) { - //Add warning in flash message - $this->addFlash('warning', $this->translator->trans('Monthly application %location% already exists', ['%location%' => $this->translator->trans('at '.$data['location'])])); - - //Redirect to cleanup the form - return $this->redirectToRoute('rapsys_air_session_view', ['id' => $session['id']]); - } - //Protect session fetching try { //Fetch session @@ -407,8 +398,18 @@ class ApplicationController extends DefaultController { //Remove route and controller from route defaults unset($route['_route'], $route['_controller']); + //Check if session view route + if ($name == 'rapsys_air_session_view' && !empty($route['id'])) { + //Replace id + $route['id'] = $session->getId(); + //Other routes + } else { + //Set session + $route['session'] = $session->getId(); + } + //Generate url - return $this->redirectToRoute($name, ['session' => $session->getId()]+$route); + return $this->redirectToRoute($name, $route); //No route matched } catch(MethodNotAllowedException|ResourceNotFoundException $e) { //Unset referer to fallback to default route -- 2.41.0