gestion synchro no mail

This commit is contained in:
afornerot 2021-01-21 16:23:14 +01:00
parent d883e3453c
commit a5a57cc9e0
2 changed files with 11 additions and 1 deletions

View File

@ -214,6 +214,7 @@ class SynchroUsersCommand extends Command
$result[$ldap_username]=utf8_encode($result[$ldap_username]); $result[$ldap_username]=utf8_encode($result[$ldap_username]);
if(!isset($result[$ldap_lastname])) $result[$ldap_lastname] = ""; if(!isset($result[$ldap_lastname])) $result[$ldap_lastname] = "";
if(!isset($result[$ldap_firstname])) $result[$ldap_firstname] = ""; if(!isset($result[$ldap_firstname])) $result[$ldap_firstname] = "";
if(!array_key_exists($ldap_email,$result)||empty($result[$ldap_email])) $result[$ldap_email]=$result[$ldap_username]."@nomail.fr";
$result[$ldap_email]=strtolower($result[$ldap_email]); $result[$ldap_email]=strtolower($result[$ldap_email]);
$result[$ldap_email]=utf8_encode($result[$ldap_email]); $result[$ldap_email]=utf8_encode($result[$ldap_email]);
@ -246,7 +247,7 @@ class SynchroUsersCommand extends Command
if($user->getLastname()!=$result[$ldap_lastname]||$user->getFirstname()!=$result[$ldap_firstname]||$user->getEmail()!=$result[$ldap_email]||$toadmin) { if($user->getLastname()!=$result[$ldap_lastname]||$user->getFirstname()!=$result[$ldap_firstname]||$user->getEmail()!=$result[$ldap_email]||$toadmin) {
$usermail=$this->em->getRepository('App:User')->findOneBy(array('email' => $result[$ldap_email])); $usermail=$this->em->getRepository('App:User')->findOneBy(array('email' => $result[$ldap_email]));
if($usermail!=$user) { if($usermail&&$usermail!=$user) {
array_push($tberrors," - Modification dans Bundle impossible >> ".$result[$ldap_username]." un autre utilisateur a déjà ce mail = ".$result[$ldap_email]); array_push($tberrors," - Modification dans Bundle impossible >> ".$result[$ldap_username]." un autre utilisateur a déjà ce mail = ".$result[$ldap_email]);
} }
else { else {

View File

@ -66,6 +66,12 @@ class SecurityController extends AbstractController
// Récupération Attribut // Récupération Attribut
$attributes = \phpCAS::getAttributes(); $attributes = \phpCAS::getAttributes();
// Init
$username = "";
$email = "";
$lastname = "";
$firstname = "";
// Rechercher l'utilisateur // Rechercher l'utilisateur
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
if(isset($attributes[$this->getParameter('casUsername')])) if(isset($attributes[$this->getParameter('casUsername')]))
@ -80,6 +86,9 @@ class SecurityController extends AbstractController
if(isset($attributes[$this->getParameter('casFirstname')])) if(isset($attributes[$this->getParameter('casFirstname')]))
$firstname = $attributes[$this->getParameter('casFirstname')]; $firstname = $attributes[$this->getParameter('casFirstname')];
// Cas nomail
if(empty($email)) $email = $username."@nomail.com";
$user = $em->getRepository('App:User')->findOneBy(array("username"=>$username)); $user = $em->getRepository('App:User')->findOneBy(array("username"=>$username));
$exists = $user ? true : false; $exists = $user ? true : false;