Commit 3cf5dc09 by Julien Jorry

Fix bug on password erratic changed + php cs fixer on files

parent 8b9d66b1
...@@ -208,7 +208,7 @@ class AdherentAdmin extends AbstractAdmin ...@@ -208,7 +208,7 @@ class AdherentAdmin extends AbstractAdmin
$password = rtrim(strtr(base64_encode($bytes), '+/', '-_'), '='); $password = rtrim(strtr(base64_encode($bytes), '+/', '-_'), '=');
$adherent->getUser()->setPassword($password); $adherent->getUser()->setPassword($password);
} }
$this->userManager->updateUser($adherent->getUser()); $this->userManager->updateCanonicalFields($adherent->getUser());
$adherent->getUser()->createEmailToken(); $adherent->getUser()->createEmailToken();
$account = $em->getRepository(AccountAdherent::class)->findOneBy(['adherent' => $adherent, 'currency' => CurrencyEnum::CURRENCY_EMLC]); $account = $em->getRepository(AccountAdherent::class)->findOneBy(['adherent' => $adherent, 'currency' => CurrencyEnum::CURRENCY_EMLC]);
if (null == $account) { if (null == $account) {
...@@ -257,12 +257,12 @@ class AdherentAdmin extends AbstractAdmin ...@@ -257,12 +257,12 @@ class AdherentAdmin extends AbstractAdmin
'advanced_filter' => false, 'advanced_filter' => false,
]) ])
->add('createdAt', 'doctrine_orm_datetime_range', [ ->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class, 'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de création' 'label' => 'Date de création',
]) ])
->add('updatedAt', 'doctrine_orm_datetime_range', [ ->add('updatedAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class, 'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de mise à jour' 'label' => 'Date de mise à jour',
]) ])
; ;
} }
...@@ -453,7 +453,7 @@ class AdherentAdmin extends AbstractAdmin ...@@ -453,7 +453,7 @@ class AdherentAdmin extends AbstractAdmin
$datagrid->buildPager(); $datagrid->buildPager();
$query = $datagrid->getQuery(); $query = $datagrid->getQuery();
$query->select('DISTINCT '.current($query->getRootAliases())); $query->select('DISTINCT ' . current($query->getRootAliases()));
$query->setFirstResult($firstResult); $query->setFirstResult($firstResult);
$query->setMaxResults($maxResult); $query->setMaxResults($maxResult);
......
...@@ -433,7 +433,7 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -433,7 +433,7 @@ class PrestataireAdmin extends AbstractAdmin
} }
} }
$user->addPossiblegroup($groupePresta); $user->addPossiblegroup($groupePresta);
$this->userManager->updateUser($user); $this->userManager->updateCanonicalFields($user);
$em->persist($user); $em->persist($user);
if ($newUser) { if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $this->getRequest())); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $this->getRequest()));
......
...@@ -25,12 +25,10 @@ use App\Enum\MoyenEnum; ...@@ -25,12 +25,10 @@ use App\Enum\MoyenEnum;
use App\Events\MLCEvents; use App\Events\MLCEvents;
use App\Form\Type\ImportFormType; use App\Form\Type\ImportFormType;
use App\Utils\CustomEntityManager; use App\Utils\CustomEntityManager;
use App\Utils\OperationFactory;
use App\Utils\OperationUtils; use App\Utils\OperationUtils;
use Behat\Transliterator\Transliterator; use Behat\Transliterator\Transliterator;
use DateTime; use DateTime;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use FOS\UserBundle\Event\UserEvent; use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\Model\UserManagerInterface; use FOS\UserBundle\Model\UserManagerInterface;
use FOS\UserBundle\Util\TokenGeneratorInterface; use FOS\UserBundle\Util\TokenGeneratorInterface;
...@@ -137,7 +135,7 @@ class ImportController extends CRUDController ...@@ -137,7 +135,7 @@ class ImportController extends CRUDController
// $this->em->getConnection()->rollBack(); // Rollback all previous commit ! // $this->em->getConnection()->rollBack(); // Rollback all previous commit !
$this->addFlash( $this->addFlash(
'error', 'error',
"Il y a eu une erreur lors de l'import : ".$e->getMessage() "Il y a eu une erreur lors de l'import : " . $e->getMessage()
); );
} }
...@@ -191,6 +189,7 @@ class ImportController extends CRUDController ...@@ -191,6 +189,7 @@ class ImportController extends CRUDController
return $result; return $result;
} }
/** /**
* Open and parse .CSV file. * Open and parse .CSV file.
* *
...@@ -838,13 +837,13 @@ class ImportController extends CRUDController ...@@ -838,13 +837,13 @@ class ImportController extends CRUDController
if (!empty($adherent->getId())) { if (!empty($adherent->getId())) {
if (1 == count($cotisationDetailsArray)) { if (1 == count($cotisationDetailsArray)) {
$cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetails), date("Y")); $cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetails), date('Y'));
} else { } else {
$cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetailsArray[0]), $cotisationDetailsArray[1]); $cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetailsArray[0]), $cotisationDetailsArray[1]);
} }
} }
if (!empty($cotisationFound)) { if (!empty($cotisationFound)) {
$this->addWarning($row, $line, 'cotisation', $this->translator->trans("Cotisation déjà trouvée pour l'année ") . (1 == count($cotisationDetailsArray)) ? date("Y") : $cotisationDetailsArray[1]); $this->addWarning($row, $line, 'cotisation', $this->translator->trans("Cotisation déjà trouvée pour l'année ") . (1 == count($cotisationDetailsArray)) ? date('Y') : $cotisationDetailsArray[1]);
unset($cotisationFound); unset($cotisationFound);
} else { } else {
$cotisation = new CotisationAdherent(); $cotisation = new CotisationAdherent();
...@@ -859,7 +858,7 @@ class ImportController extends CRUDController ...@@ -859,7 +858,7 @@ class ImportController extends CRUDController
$cotisation->setMoyen(MoyenEnum::MOYEN_AUTRE); $cotisation->setMoyen(MoyenEnum::MOYEN_AUTRE);
if (1 == count($cotisationDetailsArray)) { if (1 == count($cotisationDetailsArray)) {
$cotisation->setMontant(intval($cotisationDetails)); $cotisation->setMontant(intval($cotisationDetails));
$cotisation->getCotisationInfos()->setAnnee(date("Y")); $cotisation->getCotisationInfos()->setAnnee(date('Y'));
$cotisation->getCotisationInfos()->setDebut($now); $cotisation->getCotisationInfos()->setDebut($now);
$cotisation->getCotisationInfos()->setFin(new DateTime('+ 1 year')); $cotisation->getCotisationInfos()->setFin(new DateTime('+ 1 year'));
} else { } else {
...@@ -910,7 +909,6 @@ class ImportController extends CRUDController ...@@ -910,7 +909,6 @@ class ImportController extends CRUDController
++$this->nbsuccess; ++$this->nbsuccess;
$user->setPasswordRequestedAt(new \DateTime()); $user->setPasswordRequestedAt(new \DateTime());
if (!$this->test) { if (!$this->test) {
$this->userManager->updateUser($user, false);
if ($this->sendemail) { if ($this->sendemail) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $this->getRequest())); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $this->getRequest()));
} }
...@@ -1002,15 +1000,15 @@ class ImportController extends CRUDController ...@@ -1002,15 +1000,15 @@ class ImportController extends CRUDController
continue; continue;
} }
$exp = $this->getEntityFromData($exp_type, $exp_id, $exp_name); $exp = $this->getEntityFromData($exp_type, $exp_id, $exp_name);
if ($exp === null) { if (null === $exp) {
$this->addError($row, $line, 'exp', $this->translator->trans("L'expediteur est introuvable !")); $this->addError($row, $line, 'exp', $this->translator->trans("L'expediteur est introuvable !"));
++$this->nberrors; ++$this->nberrors;
++$line; ++$line;
continue; continue;
} }
$dest = $this->getEntityFromData($dest_type, $dest_id, $dest_name); $dest = $this->getEntityFromData($dest_type, $dest_id, $dest_name);
if ($dest === null) { if (null === $dest) {
$this->addError($row, $line, 'dest', $this->translator->trans("Le destinataire est introuvable !")); $this->addError($row, $line, 'dest', $this->translator->trans('Le destinataire est introuvable !'));
++$this->nberrors; ++$this->nberrors;
++$line; ++$line;
continue; continue;
...@@ -1039,14 +1037,14 @@ class ImportController extends CRUDController ...@@ -1039,14 +1037,14 @@ class ImportController extends CRUDController
} }
$typeFlux = $row['type']; $typeFlux = $row['type'];
if (!in_array($typeFlux, FluxEnum::getAvailableTypes())) { if (!in_array($typeFlux, FluxEnum::getAvailableTypes())) {
$this->addError($row, $line, 'type', $this->translator->trans("Le type de flux est invalide (types attendus : ".implode(', ', FluxEnum::getAvailableTypes()).") !")); $this->addError($row, $line, 'type', $this->translator->trans('Le type de flux est invalide (types attendus : ' . implode(', ', FluxEnum::getAvailableTypes()) . ') !'));
++$this->nberrors; ++$this->nberrors;
++$line; ++$line;
continue; continue;
} }
$moyen = $row['moyen']; $moyen = $row['moyen'];
if (!in_array($moyen, MoyenEnum::getAvailableTypes())) { if (!in_array($moyen, MoyenEnum::getAvailableTypes())) {
$this->addError($row, $line, 'moyen', $this->translator->trans("Le moyen est invalide (moyens attendus : ".implode(', ', MoyenEnum::getAvailableTypes()).") !")); $this->addError($row, $line, 'moyen', $this->translator->trans('Le moyen est invalide (moyens attendus : ' . implode(', ', MoyenEnum::getAvailableTypes()) . ') !'));
++$this->nberrors; ++$this->nberrors;
++$line; ++$line;
continue; continue;
...@@ -1092,7 +1090,7 @@ class ImportController extends CRUDController ...@@ -1092,7 +1090,7 @@ class ImportController extends CRUDController
$this->em->flush(); $this->em->flush();
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->addError($row, $line, 'all', $this->translator->trans("L'enregistrement du flux a posé problème ! ".$e->getMessage())); $this->addError($row, $line, 'all', $this->translator->trans("L'enregistrement du flux a posé problème ! " . $e->getMessage()));
++$this->nberrors; ++$this->nberrors;
++$line; ++$line;
continue; continue;
...@@ -1107,13 +1105,13 @@ class ImportController extends CRUDController ...@@ -1107,13 +1105,13 @@ class ImportController extends CRUDController
{ {
$entity = null; $entity = null;
$idNameOrEmailSlug = $this->slugify($idNameOrEmail); $idNameOrEmailSlug = $this->slugify($idNameOrEmail);
if ($type == 'prestataire') { if ('prestataire' == $type) {
if (!empty($idNameOrEmail)) { if (!empty($idNameOrEmail)) {
$entity = $this->em->getRepository(Prestataire::class)->findOneBy(['slug' => $idNameOrEmailSlug]); $entity = $this->em->getRepository(Prestataire::class)->findOneBy(['slug' => $idNameOrEmailSlug]);
} elseif (!empty($idmlc)) { } elseif (!empty($idmlc)) {
$entity = $this->em->getRepository(Prestataire::class)->findOneBy(['idmlc' => $idmlc]); $entity = $this->em->getRepository(Prestataire::class)->findOneBy(['idmlc' => $idmlc]);
} }
} elseif ($type == 'adherent') { } elseif ('adherent' == $type) {
if (!empty($idNameOrEmail)) { if (!empty($idNameOrEmail)) {
$userFound = $this->em->getRepository(User::class)->findOneBy(['username' => $idNameOrEmail]); $userFound = $this->em->getRepository(User::class)->findOneBy(['username' => $idNameOrEmail]);
if (!empty($userFound)) { if (!empty($userFound)) {
...@@ -1122,15 +1120,15 @@ class ImportController extends CRUDController ...@@ -1122,15 +1120,15 @@ class ImportController extends CRUDController
} elseif (!empty($idmlc)) { } elseif (!empty($idmlc)) {
$entity = $this->em->getRepository(Adherent::class)->findOneBy(['idmlc' => $idmlc]); $entity = $this->em->getRepository(Adherent::class)->findOneBy(['idmlc' => $idmlc]);
} }
} elseif ($type == 'siege' && $exp_id == 'siege') { } elseif ('siege' == $type && 'siege' == $exp_id) {
$siege = $this->em->getRepository(Siege::class)->getTheOne(); $siege = $this->em->getRepository(Siege::class)->getTheOne();
} elseif ($type == 'groupe') { } elseif ('groupe' == $type) {
if (!empty($idNameOrEmail)) { if (!empty($idNameOrEmail)) {
$entity = $this->em->getRepository(Groupe::class)->findOneBy(['slug' => $idNameOrEmailSlug]); $entity = $this->em->getRepository(Groupe::class)->findOneBy(['slug' => $idNameOrEmailSlug]);
} elseif (!empty($idmlc)) { } elseif (!empty($idmlc)) {
$entity = $this->em->getRepository(Groupe::class)->findOneBy(['idmlc' => $idmlc]); $entity = $this->em->getRepository(Groupe::class)->findOneBy(['idmlc' => $idmlc]);
} }
} elseif ($type == 'comptoir') { } elseif ('comptoir' == $type) {
if (!empty($idNameOrEmail)) { if (!empty($idNameOrEmail)) {
$entity = $this->em->getRepository(Comptoir::class)->findOneBy(['slug' => $idNameOrEmailSlug]); $entity = $this->em->getRepository(Comptoir::class)->findOneBy(['slug' => $idNameOrEmailSlug]);
} elseif (!empty($idmlc)) { } elseif (!empty($idmlc)) {
......
...@@ -23,7 +23,6 @@ use Symfony\Component\Form\FormError; ...@@ -23,7 +23,6 @@ use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class UserPrestataireController extends FluxController class UserPrestataireController extends FluxController
{ {
...@@ -53,11 +52,11 @@ class UserPrestataireController extends FluxController ...@@ -53,11 +52,11 @@ class UserPrestataireController extends FluxController
$errors = []; $errors = [];
foreach ($caissiers as $caissier) { foreach ($caissiers as $caissier) {
$emailConstraint = new Assert\Email(); $emailConstraint = new Assert\Email();
$emailConstraint->message = "Courriel '".$caissier."' invalide!"; $emailConstraint->message = "Courriel '" . $caissier . "' invalide!";
$errors[] = $this->validator->validate( $errors[] = $this->validator->validate(
$caissier, $caissier,
$emailConstraint $emailConstraint
); );
} }
$errorText = ''; $errorText = '';
...@@ -128,7 +127,7 @@ class UserPrestataireController extends FluxController ...@@ -128,7 +127,7 @@ class UserPrestataireController extends FluxController
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $request)); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $request));
} }
$user->addPossiblegroup($groupePresta); $user->addPossiblegroup($groupePresta);
$this->userManager->updateUser($user); $this->userManager->updateCanonicalFields($user);
$this->em->persist($user); $this->em->persist($user);
if ($newUser) { if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $request)); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $request));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment