Commit 83997b94 authored by root's avatar root
Browse files

Merge branch 'master' of https://git.unicaen.fr/dsi/preecog

parents c1d4a7af 2aa0d80e
Loading
Loading
Loading
Loading
+4 −7
Changes for module/Application/src/Application/Controller/IndexController.php: 4 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -32,18 +32,15 @@ class IndexController extends AbstractActionController
        /** @var User $connectedUser */
        $connectedUser = $this->getUserService()->getConnectedUser();

        if ($this->getServiceUserContext()->getLdapUser()) {
        $agent = $this->getAgentService()->getAgentByUsername($connectedUser->getUsername());

            if ($connectedUser !== null && $agent !== null && $agent->getUtilisateur() === null) {
        if ($agent !== null && $agent->getUtilisateur() === null) {
            $agent->setUtilisateur($connectedUser);
            $this->getAgentService()->update($agent);
                $personnel = $this->getRoleService()->findByRoleId(RoleConstant::PERSONNEL);
                $hasAgent = $connectedUser->hasRole($personnel);
                if (! $hasAgent) $this->getUserService()->addRole($connectedUser, $personnel);
//            $personnel = $this->getRoleService()->findByRoleId(RoleConstant::PERSONNEL);
//            $hasAgent = $connectedUser->hasRole($personnel);
//            if (! $hasAgent) $this->getUserService()->addRole($connectedUser, $personnel);
            return $this->redirect()->toRoute('agent/afficher', ['agent' => $agent->getId()], [], true);
        }
        }

        /** @var Role $connectedRole */
        $connectedRole = $this->getUserService()->getConnectedRole();