init schedule
This commit is contained in:
@@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\ClassMetadata;
|
|||||||
use Doctrine\ORM\Id\AssignedGenerator;
|
use Doctrine\ORM\Id\AssignedGenerator;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Entity\Nature;
|
||||||
|
|
||||||
|
|
||||||
class AppInitCommand extends Command
|
class AppInitCommand extends Command
|
||||||
@@ -50,6 +51,18 @@ class AppInitCommand extends Command
|
|||||||
|
|
||||||
$output->writeln('APP = Default Data');
|
$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");
|
$this->insertUser("admin","admin");
|
||||||
|
|
||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
@@ -57,6 +70,22 @@ class AppInitCommand extends Command
|
|||||||
return $this->em->flush();
|
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() {
|
protected function insertUser() {
|
||||||
$metadata = $this->em->getClassMetaData('App:User');
|
$metadata = $this->em->getClassMetaData('App:User');
|
||||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||||
|
@@ -61,8 +61,6 @@ class SecurityController extends AbstractController
|
|||||||
|
|
||||||
// Récupération Attribut
|
// Récupération Attribut
|
||||||
$attributes = \phpCAS::getAttributes();
|
$attributes = \phpCAS::getAttributes();
|
||||||
dump($username);
|
|
||||||
dump($attributes);
|
|
||||||
|
|
||||||
// Suppression des Attributs en tableaux
|
// Suppression des Attributs en tableaux
|
||||||
foreach ($attributes as $key => $value) {
|
foreach ($attributes as $key => $value) {
|
||||||
@@ -99,7 +97,7 @@ class SecurityController extends AbstractController
|
|||||||
$user->setPassword("CASPWD-".$username);
|
$user->setPassword("CASPWD-".$username);
|
||||||
$user->setSalt("CASPWD-".$username);
|
$user->setSalt("CASPWD-".$username);
|
||||||
|
|
||||||
$user->setRole("ROLE_USER");
|
$user->setRoles(["ROLE_USER"]);
|
||||||
|
|
||||||
$em->persist($user);
|
$em->persist($user);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
@@ -134,14 +132,26 @@ class SecurityController extends AbstractController
|
|||||||
|
|
||||||
|
|
||||||
public function logout() {
|
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('security.token_storage')->setToken(null);
|
||||||
$this->get('session')->invalidate();
|
$this->get('session')->invalidate();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl("cnous_portal_homepage"));
|
return $this->redirect($this->generateUrl("app_home"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function logoutcas() {
|
public function logoutcas() {
|
||||||
// Init Client CAS
|
// Init Client CAS
|
||||||
\phpCAS::setDebug('/var/www/html/schedule/var/log/cas.log');
|
\phpCAS::setDebug('/var/www/html/schedule/var/log/cas.log');
|
||||||
@@ -152,5 +162,7 @@ class SecurityController extends AbstractController
|
|||||||
// Logout
|
// Logout
|
||||||
$url=$this->generateUrl('app_home', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
$url=$this->generateUrl('app_home', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
\phpCAS::logout(array("service"=>$url));
|
\phpCAS::logout(array("service"=>$url));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,13 @@ class Nature
|
|||||||
*/
|
*/
|
||||||
private $tasks;
|
private $tasks;
|
||||||
|
|
||||||
|
public function setId(int $id): self
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->tasks = new ArrayCollection();
|
$this->tasks = new ArrayCollection();
|
||||||
|
Reference in New Issue
Block a user