diff --git a/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php b/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php index c351f5d5..a33dfec5 100644 --- a/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php +++ b/src/ninegate-1.0/src/Cadoles/CASBundle/Controller/SecurityController.php @@ -28,7 +28,7 @@ class SecurityController extends Controller $masteridentity=$this->getParameter("masteridentity"); // Init Client CAS - \phpCAS::setDebug(false); + \phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log"); \phpCAS::client(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false); \phpCAS::setNoCasServerValidation(); @@ -42,12 +42,6 @@ class SecurityController extends Controller // Récupération Attribut $attributes = \phpCAS::getAttributes(); - // Suppression des Attributs en tableaux - foreach ($attributes as $key => $value) { - if(is_array($value)) - unset($attributes[$key]); - } - // Rechercher l'utilisateur $em = $this->getDoctrine()->getManager(); if(isset($attributes[$this->getParameter('user_attr_cas_username')])) @@ -62,6 +56,7 @@ class SecurityController extends Controller if(isset($attributes[$this->getParameter('user_attr_cas_firstname')])) $firstname = $attributes[$this->getParameter('user_attr_cas_firstname')]; + $user = $em->getRepository('CadolesCoreBundle:User')->findOneBy(array("username"=>$username)); $exists = $user ? true : false; @@ -108,7 +103,8 @@ class SecurityController extends Controller $em->flush(); // On calcule les groupes de l'utilisateur - $groups=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes); + $user=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes); + } } else { @@ -122,14 +118,15 @@ class SecurityController extends Controller // On s'assure que le niveau 02 appartient bien au niveau 01 calculé $sameniveau01=(!is_null($user->getNiveau02())&&$niveau01==$user->getNiveau02()->getNiveau01()); - // On calcule les groupes de l'utilisateur - $user=$groups=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes); - $user->setLastname($lastname); $user->setFirstname($firstname); $user->setEmail($email); if(!$sameniveau01) $user->setNiveau02(null); - + + // On calcule les groupes de l'utilisateur + $user=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes); + + $em->persist($user); $em->flush(); } @@ -179,4 +176,37 @@ class SecurityController extends Controller $url=$this->generateUrl('cadoles_core_home', array(), UrlGeneratorInterface::ABSOLUTE_URL); \phpCAS::logout(array("service"=>$url)); } + + public function testAction() { + $em = $this->getDoctrine()->getManager(); + + // Init Client CAS + \phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log"); + \phpCAS::client(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false); + \phpCAS::setNoCasServerValidation(); + + + // Authentification + \phpCAS::forceAuthentication(); + + // Récupération UID + $username = \phpCAS::getUser(); + + // Récupération Attribut + $attributes = \phpCAS::getAttributes(); + $user = $em->getRepository('CadolesCoreBundle:User')->findOneBy(array("username"=>$username)); + $niveau01=$em->getRepository('CadolesCoreBundle:Niveau01')->calculateNiveau01($attributes); + $user=$em->getRepository('CadolesCoreBundle:Group')->calculateGroup($user,$attributes); + + return $this->render('CadolesCASBundle:Test:test.html.twig',[ + 'useheader' => true, + 'usemenu' => false, + 'usesidebar' => false, + 'attributes' => $attributes, + 'user' => $user, + 'username' => $username, + 'niveau01' => $niveau01, + ]); + + } } diff --git a/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml index 728e4a44..f97aa770 100644 --- a/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/config/routing.yml @@ -6,3 +6,7 @@ cas_sp.logout: path: /logout defaults: { _controller: CadolesCASBundle:Security:logout } +cas_sp.test: + path: /test + defaults: { _controller: CadolesCASBundle:Security:test } + diff --git a/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/views/Test/test.html.twig b/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/views/Test/test.html.twig new file mode 100644 index 00000000..a1c7b0c7 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CASBundle/Resources/views/Test/test.html.twig @@ -0,0 +1,35 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +