diff --git a/src/schedule-2.0/src/Command/AppInitCommand.php b/src/schedule-2.0/src/Command/AppInitCommand.php index 222e812..275f753 100644 --- a/src/schedule-2.0/src/Command/AppInitCommand.php +++ b/src/schedule-2.0/src/Command/AppInitCommand.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Id\AssignedGenerator; use App\Entity\User; +use App\Entity\Nature; class AppInitCommand extends Command @@ -50,6 +51,18 @@ class AppInitCommand extends Command $output->writeln('APP = Default Data'); + // Création des natures par défaut + $this->insertNature(-200,"Congés",true); + $this->insertNature(-190,"Temps Partiel",false); + $this->insertNature(-100,"Non Travaillé",false); + $this->insertNature(-90,"Non Facturable",false); + $this->insertNature(-80,"Prestation",false); + $this->insertNature(-70,"Intégration",false); + $this->insertNature(-60,"Formation",false); + $this->insertNature(-50,"Ticket",false); + $this->insertNature(-40,"Maintenance",false); + + // Création du compte admin si non existant $this->insertUser("admin","admin"); $output->writeln(''); @@ -57,6 +70,22 @@ class AppInitCommand extends Command return $this->em->flush(); } + protected function insertNature($id,$name,$isvacation) { + $metadata = $this->em->getClassMetaData('App:Nature'); + $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); + $metadata->setIdGenerator(new AssignedGenerator()); + + $entity = $this->em->getRepository('App:Nature')->find($id); + if(!$entity) { + $entity = new Nature; + $entity->setId($id); + $entity->setName($name); + $entity->setIsvacation($isvacation); + $this->em->persist($entity); + $this->em->flush(); + } + } + protected function insertUser() { $metadata = $this->em->getClassMetaData('App:User'); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); diff --git a/src/schedule-2.0/src/Controller/SecurityController.php b/src/schedule-2.0/src/Controller/SecurityController.php index 3e221ed..0b98a22 100755 --- a/src/schedule-2.0/src/Controller/SecurityController.php +++ b/src/schedule-2.0/src/Controller/SecurityController.php @@ -61,8 +61,6 @@ class SecurityController extends AbstractController // Récupération Attribut $attributes = \phpCAS::getAttributes(); - dump($username); - dump($attributes); // Suppression des Attributs en tableaux foreach ($attributes as $key => $value) { @@ -99,7 +97,7 @@ class SecurityController extends AbstractController $user->setPassword("CASPWD-".$username); $user->setSalt("CASPWD-".$username); - $user->setRole("ROLE_USER"); + $user->setRoles(["ROLE_USER"]); $em->persist($user); $em->flush(); @@ -134,14 +132,26 @@ class SecurityController extends AbstractController public function logout() { + $auth_mode=$this->getParameter("appAuth"); + switch($auth_mode) { + case "MYSQL": + return $this->logoutMYSQL(); + break; + + case "CAS": + return $this->logoutCAS(); + break; + } + + } + + public function logoutMYSQL() { $this->get('security.token_storage')->setToken(null); $this->get('session')->invalidate(); - return $this->redirect($this->generateUrl("cnous_portal_homepage")); + return $this->redirect($this->generateUrl("app_home")); } - - public function logoutcas() { // Init Client CAS \phpCAS::setDebug('/var/www/html/schedule/var/log/cas.log'); @@ -152,5 +162,7 @@ class SecurityController extends AbstractController // Logout $url=$this->generateUrl('app_home', array(), UrlGeneratorInterface::ABSOLUTE_URL); \phpCAS::logout(array("service"=>$url)); + + return true; } } diff --git a/src/schedule-2.0/src/Entity/Nature.php b/src/schedule-2.0/src/Entity/Nature.php index 5ac65eb..ad9886a 100644 --- a/src/schedule-2.0/src/Entity/Nature.php +++ b/src/schedule-2.0/src/Entity/Nature.php @@ -39,6 +39,13 @@ class Nature */ private $tasks; + public function setId(int $id): self + { + $this->id = $id; + + return $this; + } + public function __construct() { $this->tasks = new ArrayCollection();