This commit is contained in:
root 2019-06-14 15:07:54 +02:00
parent 612012d480
commit f85b6e848b
6 changed files with 144 additions and 111 deletions

View File

@ -8,8 +8,8 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
(-100, 'DRAAF', '130007107'); (-100, 'DRAAF', '130007107');
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}XzeVqnrNOqCyH0z7F5gEVxBKwivMttoy (-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}xiNakN3H44Yrsb6ZrCP+/VGKob+TEyKy
', 'admin@transnum.cadol.es', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple'); ', 'afornerot@cadoles.com', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');

View File

@ -172,6 +172,8 @@ class RegistrationController extends Controller
public function submitAction(Request $request) public function submitAction(Request $request)
{ {
$moderegistration = $this->getParameter('moderegistration'); $moderegistration = $this->getParameter('moderegistration');
$masteridentity = $this->getParameter('masteridentity'); $masteridentity = $this->getParameter('masteridentity');
if($moderegistration=="none"||$masteridentity!="SQL") if($moderegistration=="none"||$masteridentity!="SQL")
@ -282,6 +284,8 @@ class RegistrationController extends Controller
$message = $this->container->get('cadoles.core.service.mail'); $message = $this->container->get('cadoles.core.service.mail');
$message->sendEmail($template, $mail_params, $to, $from, $fromName); $message->sendEmail($template, $mail_params, $to, $from, $fromName);
} }
// si oui : Domaine de confiance : email de validation d'inscription directement à l'utilisateur // si oui : Domaine de confiance : email de validation d'inscription directement à l'utilisateur
@ -319,24 +323,33 @@ class RegistrationController extends Controller
$em->flush(); $em->flush();
// A voir retour sur un écran d'info indiquant si validation par admion ou s'il doit matter ses email // A voir retour sur un écran d'info indiquant si validation par admion ou s'il doit matter ses email
return $this->render($this->labelentity.':info.html.twig', [ $this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', "info");
return $this->redirectToRoute('cadoles_core_registration_info');
}
else {
return $this->render($this->labelentity.':edit.html.twig', [
'useheader' => true, 'useheader' => true,
'usemenu' => false, 'usemenu' => false,
'usesidebar' => false, 'usesidebar' => false,
'info' => $info, $this->labeldata => $data,
'mode' => "info" 'mode' => 'submit',
'form' => $form->createView()
]); ]);
} }
return $this->render($this->labelentity.':edit.html.twig', [ }
public function infoAction(Request $request)
{
$info = $this->get('session')->get('registrationinfo');
$mode = $this->get('session')->get('registrationmode');
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true, 'useheader' => true,
'usemenu' => false, 'usemenu' => false,
'usesidebar' => false, 'usesidebar' => false,
$this->labeldata => $data, 'info' => $info,
'mode' => 'submit', 'mode' => $mode
'form' => $form->createView()
]); ]);
} }
public function sendAction($id,Request $request) public function sendAction($id,Request $request)
@ -440,12 +453,18 @@ class RegistrationController extends Controller
if(!$data) { if(!$data) {
$info="Clé de validation invalide"; $info="Clé de validation invalide";
$mode="danger"; $mode="danger";
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
} }
else { else {
$url=$this->getParameter('eportail_login'); $url=$this->getUrlLogin();
$info="<p>Votre compte est à présent activé</p><p>Vous allez être redirigé vers la mire de connexion</p><p><a href='".$url."'>Connexion</a>"; $info="<p>Votre compte est à présent activé</p><p>Vous allez être redirigé vers la mire de connexion</p><p><a href='".$url."'>Connexion</a>";
$mode="success"; $mode="success";
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
// Initialisation de l'enregistrement // Initialisation de l'enregistrement
$user = new User(); $user = new User();
$user->setAvatar("noavatar.png"); $user->setAvatar("noavatar.png");
@ -487,14 +506,7 @@ class RegistrationController extends Controller
$em->flush(); $em->flush();
} }
return $this->redirectToRoute('cadoles_core_registration_info');
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
} }
@ -612,14 +624,10 @@ class RegistrationController extends Controller
// Info // Info
$info="Vous allez recevoir un mail avec lien qui vous permettra de réinitialiser votre mot de passe"; $info="Vous allez recevoir un mail avec lien qui vous permettra de réinitialiser votre mot de passe";
$mode="success"; $mode="info";
return $this->render($this->labelentity.':info.html.twig', [ $this->get('session')->set('registrationinfo', $info);
'useheader' => true, $this->get('session')->set('registrationmode', $mode);
'usemenu' => false, return $this->redirectToRoute('cadoles_core_registration_info');
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
} }
// Affichage du formulaire // Affichage du formulaire
@ -654,14 +662,9 @@ class RegistrationController extends Controller
if(!$user) { if(!$user) {
$info="Clé de validation invalide"; $info="Clé de validation invalide";
$mode="danger"; $mode="danger";
$this->get('session')->set('registrationinfo', $info);
return $this->render($this->labelentity.':info.html.twig', [ $this->get('session')->set('registrationmode', $mode);
'useheader' => true, return $this->redirectToRoute('cadoles_core_registration_info');
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
} }
else { else {
// Création du formulaire // Création du formulaire
@ -715,18 +718,12 @@ class RegistrationController extends Controller
$em->persist($user[0]); $em->persist($user[0]);
$em->flush(); $em->flush();
$info="Nouveau mot de passe prise en compte<br>Vous allez être rediriger vers la mire d'authentification"; $url=$this->getUrlLogin();
$info="<p>Nouveau mot de passe prise en compte</p><p>Vous allez être redirigé vers la mire de connexion</p><p><a href='".$url."'>Connexion</a>";
$mode="success"; $mode="success";
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
return $this->render($this->labelentity.':info.html.twig', [ return $this->redirectToRoute('cadoles_core_registration_info');
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
} }
// Affichage du formulaire // Affichage du formulaire
@ -739,6 +736,24 @@ class RegistrationController extends Controller
} }
} }
protected function getUrlLogin()
{
$mode_auth=$this->getParameter("mode_auth");
if($mode_auth == "SAML")
$url = $this->generateUrl('lightsaml_sp.login');
elseif($mode_auth == "CAS")
$url = $this->generateUrl('cas_sp.login');
elseif($mode_auth == "SQL")
$url = $this->generateUrl('cadoles_core_login');
elseif($mode_auth == "LDAP")
$url = $this->generateUrl('cadoles_core_ldap_login');
else
$url="";
return $url;
}
protected function getDatas() protected function getDatas()
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();

View File

@ -169,6 +169,10 @@ cadoles_core_registration:
path: /registration path: /registration
defaults: { _controller: CadolesCoreBundle:Registration:submit } defaults: { _controller: CadolesCoreBundle:Registration:submit }
cadoles_core_registration_info:
path: /registration/info
defaults: { _controller: CadolesCoreBundle:Registration:info }
cadoles_core_registration_validation: cadoles_core_registration_validation:
path: /registration/validation/{key} path: /registration/validation/{key}
defaults: { _controller: CadolesCoreBundle:Registration:validation } defaults: { _controller: CadolesCoreBundle:Registration:validation }

View File

@ -16,17 +16,20 @@
{% if mode=="success" %} {% if mode=="success" %}
$(document).ready(function() { $(document).ready(function() {
{% if eportail_sync %} // Redirection vers la mire d'authentification
// Redirection vers la mire de connexion d'ePortail setTimeout(function(){
setTimeout(function(){ {% if mode_auth == "SAML" %}
window.location.href="{{ eportail_login }}"; window.location.href="{{ path("lightsaml_sp.login") }}";
}, 6000); {% elseif mode_auth == "CAS" %}
{% else %} window.location.href="{{ path("cas_sp.login") }}";
// Redirection vers la mire d'authentification {% elseif mode_auth == "SQL" %}
setTimeout(function(){ window.location.href="{{ path("cadoles_core_login") }}";
window.location.href="{{ path("cadoles_core_login") }}"; {% elseif mode_auth == "LDAP" %}
}, 6000); window.location.href="{{ path("cadoles_core_ldap_login") }}";
{% endif %} {% endif %}
}, 6000);
}); });
{% endif %} {% endif %}

View File

@ -228,11 +228,15 @@ class jsonRPCClient
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (isset($this->httpErrors[$httpCode])) if (isset($this->httpErrors[$httpCode]))
{ {
echo 'Response Http Error - ' . $this->httpErrors[$httpCode];
return $false;
throw new \RuntimeException('Response Http Error - ' . $this->httpErrors[$httpCode]); throw new \RuntimeException('Response Http Error - ' . $this->httpErrors[$httpCode]);
} }
// check for curl error // check for curl error
if (0 < curl_errno($ch)) if (0 < curl_errno($ch))
{ {
echo 'Unable to connect to '.$this->url . ' Error: ' . curl_error($ch);
return $response;
throw new \RuntimeException('Unable to connect to '.$this->url . ' Error: ' . curl_error($ch)); throw new \RuntimeException('Unable to connect to '.$this->url . ' Error: ' . curl_error($ch));
} }
// close the connection // close the connection
@ -253,6 +257,7 @@ class jsonRPCClient
{ {
if ($pFailed) if ($pFailed)
{ {
return false;
throw new \RuntimeException($pErrMsg); throw new \RuntimeException($pErrMsg);
} }
} }
@ -397,37 +402,39 @@ class GetLimesurveyCommand extends Command
// list de l'ensemble des sondages invité // list de l'ensemble des sondages invité
$surveys= $myJSONRPCClient->list_surveys($sessionKey); $surveys= $myJSONRPCClient->list_surveys($sessionKey);
foreach($surveys as $survey) { if(is_array($surveys)) {
// Si le sondage est actif foreach($surveys as $survey) {
if($survey["active"]=="Y") { // Si le sondage est actif
if($survey["active"]=="Y") {
// Liste des participants // Liste des participants
$survey_id=$survey["sid"]; $survey_id=$survey["sid"];
$users = $myJSONRPCClient->list_participants($sessionKey, $survey_id, 0, 10000); $users = $myJSONRPCClient->list_participants($sessionKey, $survey_id, 0, 10000);
$token=""; $token="";
foreach($users as $user) { foreach($users as $user) {
if(isset($user["participant_info"]["email"]) && $user["participant_info"]["email"]!="") { if(isset($user["participant_info"]["email"]) && $user["participant_info"]["email"]!="") {
$entity = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["email"=>$user["participant_info"]["email"]]); $entity = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["email"=>$user["participant_info"]["email"]]);
if($entity) { if($entity) {
$surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]); $surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]);
$surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]); $surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]);
$surveydescription = $surveyproplang["surveyls_welcometext"]; $surveydescription = $surveyproplang["surveyls_welcometext"];
$surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription))); $surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription)));
$token=$user["token"]; $token=$user["token"];
$url=$widlimesurvey_url."/".$survey_id; $url=$widlimesurvey_url."/".$survey_id;
if($token!="") if($token!="")
$url.="?token=".$token; $url.="?token=".$token;
$string ='"'.$survey["sid"].'": {'; $string ='"'.$survey["sid"].'": {';
$string.='"title": '.json_encode($survey["surveyls_title"]).','; $string.='"title": '.json_encode($survey["surveyls_title"]).',';
$string.='"url": "'.$url.'",'; $string.='"url": "'.$url.'",';
$string.='"date": "'.$surveypropconf["datecreated"].'",'; $string.='"date": "'.$surveypropconf["datecreated"].'",';
$string.='"description": '.$surveydescription; $string.='"description": '.$surveydescription;
$string.='},'; $string.='},';
$this->filesystem->appendToFile($this->limefile.'-new/'.$entity->getId().'/invitation.json', $string."\n"); $this->filesystem->appendToFile($this->limefile.'-new/'.$entity->getId().'/invitation.json', $string."\n");
}
} }
} }
} }
@ -436,29 +443,31 @@ class GetLimesurveyCommand extends Command
// Pour chaque user on remonte les sondages dont ils sont propriétaires // Pour chaque user on remonte les sondages dont ils sont propriétaires
$userlimesurveys=$myJSONRPCClient->list_users($sessionKey); $userlimesurveys=$myJSONRPCClient->list_users($sessionKey);
foreach($userlimesurveys as $userlimesurvey) { if(is_array($userlimesurveys)) {
$user = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$userlimesurvey["users_name"]]); foreach($userlimesurveys as $userlimesurvey) {
if($user) { $user = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$userlimesurvey["users_name"]]);
$surveys = $myJSONRPCClient->list_surveys($sessionKey, $user->getUserName()); if($user) {
foreach($surveys as $survey) { $surveys = $myJSONRPCClient->list_surveys($sessionKey, $user->getUserName());
if(is_array($survey)) { foreach($surveys as $survey) {
if(is_array($survey)) {
if($survey["active"]=="Y") { if($survey["active"]=="Y") {
$surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]); $surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]);
$surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]); $surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]);
$surveydescription = $surveyproplang["surveyls_welcometext"]; $surveydescription = $surveyproplang["surveyls_welcometext"];
$surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription))); $surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription)));
$url=$widlimesurvey_url."/admin/survey/sa/view/surveyid/".$survey["sid"]; $url=$widlimesurvey_url."/admin/survey/sa/view/surveyid/".$survey["sid"];
$string ='"'.$survey["sid"].'": {'; $string ='"'.$survey["sid"].'": {';
$string.='"title": '.json_encode($survey["surveyls_title"]).','; $string.='"title": '.json_encode($survey["surveyls_title"]).',';
$string.='"url": "'.$url.'",'; $string.='"url": "'.$url.'",';
$string.='"date": "'.$surveypropconf["datecreated"].'",'; $string.='"date": "'.$surveypropconf["datecreated"].'",';
$string.='"description": '.$surveydescription; $string.='"description": '.$surveydescription;
$string.='},'; $string.='},';
$this->filesystem->appendToFile($this->limefile.'-new/'.$user->getId().'/survey.json', $string."\n"); $this->filesystem->appendToFile($this->limefile.'-new/'.$user->getId().'/survey.json', $string."\n");
}
} }
} }
} }
@ -466,8 +475,10 @@ class GetLimesurveyCommand extends Command
} }
// On supprime les encours pour le remplacer le new // On supprime les encours pour le remplacer le new
$fs->remove($this->limefile); if($fs->exists($this->limefile.'-new')) {
$fs->rename($this->limefile.'-new',$this->limefile); $fs->remove($this->limefile);
$fs->rename($this->limefile.'-new',$this->limefile);
}
// release the session key // release the session key
$myJSONRPCClient->release_session_key( $sessionKey ); $myJSONRPCClient->release_session_key( $sessionKey );

View File

@ -18,8 +18,8 @@
> Synchronisation posh-profil à revoir > Synchronisation posh-profil à revoir
> Séparateur milier sur datatable > Séparateur milier sur datatable
> Donner des permissions d'écritures sur les calendriers comme sur le blog > Donner des permissions d'écritures sur les calendriers comme sur le blog
> Que faire si lock sur cron depuis trop longtemps
> Couleur sur blog > Couleur sur blog
> Import de compte > Import de compte