diff --git a/src/UnicaenAuth/Controller/AuthController.php b/src/UnicaenAuth/Controller/AuthController.php index 94cf49315374c82f8dd9f2df97621bb23048221e..30d274778c75153556a4f347ea4ae55631ea15a9 100644 --- a/src/UnicaenAuth/Controller/AuthController.php +++ b/src/UnicaenAuth/Controller/AuthController.php @@ -114,6 +114,14 @@ class AuthController extends AbstractActionController public function loginAction() { if ($this->zfcUserAuthentication()->hasIdentity()) { + $roleId = $this->params()->fromPost('role', $this->params()->fromQuery('role', false)); + if ($roleId) { + $this->serviceUserContext->setSelectedIdentityRole($roleId); + } + if ($this->getRequestedRedirect()) { + $redirect = $this->redirectCallback; + return $redirect(); + } return $this->redirect()->toRoute($this->moduleOptions->getLoginRedirectRoute()); } diff --git a/src/UnicaenAuth/Service/UserContext.php b/src/UnicaenAuth/Service/UserContext.php index da6eb9914069fd76b2a4a0adb163313d2667023c..c1131c2e2769af5f70fd63ccb34f66166e234e93 100644 --- a/src/UnicaenAuth/Service/UserContext.php +++ b/src/UnicaenAuth/Service/UserContext.php @@ -325,7 +325,7 @@ class UserContext extends AbstractService implements EventManagerAwareInterface { if ($role) { if (!$this->isRoleValid($role)) { - throw new RuntimeException("Rôle spécifié invalide."); + throw new RuntimeException("Rôle spécifié invalide : '$role'"); } if ($role instanceof RoleInterface) { $role = $role->getRoleId();