@@ -45,24+45,27 @@ class ApplicationController extends AbstractController {
* @throws \RuntimeException When user has not at least guest role
*/
public function add(Request $request) {
* @throws \RuntimeException When user has not at least guest role
*/
public function add(Request $request) {
- //Prevent non-guest to access here
- $this->denyAccessUnlessGranted('ROLE_GUEST', null, $this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Guest')]));
+ //Without guest role
+ if (!$this->checker->isGranted('ROLE_GUEST')) {
+ //Throw 403
+ throw $this->createAccessDeniedException($this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('Guest')]));
@@ -154,7+157,7 @@ class ApplicationController extends AbstractController {
$session->setLength(new \DateTime('06:00:00'));
//Check if admin
$session->setLength(new \DateTime('06:00:00'));
//Check if admin
- if ($this->isGranted('ROLE_ADMIN')) {
+ if ($this->checker->isGranted('ROLE_ADMIN')) {
//Check if morning
if ($slot == 'Morning') {
//Set begin at 9h
//Check if morning
if ($slot == 'Morning') {
//Set begin at 9h
@@ -340,7+343,7 @@ class ApplicationController extends AbstractController {
}
//Check if admin
}
//Check if admin
- if (!$this->isGranted('ROLE_ADMIN') && $session->getStart() < new \DateTime('00:00:00')) {
+ if (!$this->checker->isGranted('ROLE_ADMIN') && $session->getStart() < new \DateTime('00:00:00')) {
//Add error in flash message
$this->addFlash('error', $this->translator->trans('Session in the past on %date% %location% %slot% not yet supported', ['%location%' => $this->translator->trans('at '.$data['location']), '%slot%' => $this->translator->trans('the '.strtolower(strval($data['slot']))), '%date%' => $data['date']->format('Y-m-d')]));
//Add error in flash message
$this->addFlash('error', $this->translator->trans('Session in the past on %date% %location% %slot% not yet supported', ['%location%' => $this->translator->trans('at '.$data['location']), '%slot%' => $this->translator->trans('the '.strtolower(strval($data['slot']))), '%date%' => $data['date']->format('Y-m-d')]));
@@ -361,11+364,11 @@ class ApplicationController extends AbstractController {
}
//Set user
}
//Set user
- $user = $this->getUser();
+ $user = $this->security->getUser();
//Replace with requested user for admin
//Replace with requested user for admin
- if ($this->isGranted('ROLE_ADMIN') && !empty($data['user'])) {