diff --git a/public/upload/image/profile/pp-pro-673de6dc5508e.jpg b/public/upload/image/profile/pp-pro-673de6dc5508e.jpg new file mode 100644 index 0000000..66e03d6 Binary files /dev/null and b/public/upload/image/profile/pp-pro-673de6dc5508e.jpg differ diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index f1c181b..008d756 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -175,59 +175,64 @@ class AdminController extends AbstractController #[Route('/admin/user/import', name: 'participant_import', methods: ['POST'])] public function import(Request $request, EntityManagerInterface $em, MailerInterface $mailer, UrlGeneratorInterface $urlGenerator): RedirectResponse { - $file = $request->files->get('csv_file'); - if ($file) { - $csvData = array_map('str_getcsv', file($file->getPathname())); - foreach ($csvData as $index => $row) { - if ($index === 0) continue; - $participant = new Participant(); - $participant->setNom($row[0]); - $participant->setPrenom($row[1]); - $participant->setPseudo($row[2]); - $participant->setTelephone($row[3]); - $participant->setEmail($row[4]); - $participant->setAdministrateur(false); - $participant->setActif(false); - $participant->setRoles(explode('|', $row[7])); - $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); - $em->persist($participant); + try{ + $file = $request->files->get('csv_file'); + if ($file) { + $csvData = array_map('str_getcsv', file($file->getPathname())); + foreach ($csvData as $index => $row) { + if ($index === 0) continue; + $participant = new Participant(); + $participant->setNom($row[0]); + $participant->setPrenom($row[1]); + $participant->setPseudo($row[2]); + $participant->setTelephone($row[3]); + $participant->setEmail($row[4]); + $participant->setAdministrateur(false); + $participant->setActif(false); + $participant->setRoles(explode('|', $row[7])); + $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); + $em->persist($participant); - // Générer un token unique - $token = bin2hex(random_bytes(32)); + // Générer un token unique + $token = bin2hex(random_bytes(32)); - // Enregistrer le token dans la base de données - $passwordResetToken = new PasswordResetToken(); - $passwordResetToken->setToken($token) - ->setEmail($participant->getEmail()) - ->setCreatedAt(new \DateTime()); + // Enregistrer le token dans la base de données + $passwordResetToken = new PasswordResetToken(); + $passwordResetToken->setToken($token) + ->setEmail($participant->getEmail()) + ->setCreatedAt(new \DateTime()); - $em->persist($passwordResetToken); + $em->persist($passwordResetToken); - // Générer un lien de réinitialisation - $resetLink = $urlGenerator->generate( - 'app_password_reset', - ['token' => $token], - UrlGeneratorInterface::ABSOLUTE_URL - ); + // Générer un lien de réinitialisation + $resetLink = $urlGenerator->generate( + 'app_password_reset', + ['token' => $token], + UrlGeneratorInterface::ABSOLUTE_URL + ); - // Envoyer un email de notification - $email = (new Email()) - ->from('contact@sortir.com') - ->to($participant->getEmail()) - ->subject('Sortir.com | Bienvenue sur notre site !') - ->html(" + // Envoyer un email de notification + $email = (new Email()) + ->from('contact@sortir.com') + ->to($participant->getEmail()) + ->subject('Sortir.com | Bienvenue sur notre site !') + ->html("

Bonjour $row[2],

Un administrateur du site vous a créé un compte !

Terminer la création de cotre compte : Sortir.com

Toute l'équipe de Sortir vous souhaite la bienvenue !

"); - $mailer->send($email); + $mailer->send($email); + } + $em->flush(); } - $em->flush(); + return $this->redirectToRoute('app_adminUser'); + }catch(\Exception $e){ + $this->addFlash('error', "Votre fichier contient des erreurs : " . $e->getMessage()); + return $this->redirectToRoute('app_adminUser'); } - return $this->redirectToRoute('app_adminUser'); } #[Route('/admin/user/export', name: 'participant_export')] public function export(ParticipantRepository $participantRepository): Response diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 559e3ff..38229cd 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Repository\SortieRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -10,12 +11,14 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt class MainController extends AbstractController { #[Route('/', name: 'home')] - public function index(TokenStorageInterface $tokenStorage): Response + public function index(TokenStorageInterface $tokenStorage, SortieRepository $sortieRepository): Response { $token = $tokenStorage->getToken(); $userConnect = $token?->getUser(); + $sorties = $sortieRepository->findAll(); return $this->render('main/index.html.twig', [ 'profile' => $userConnect, + 'sorties' => $sorties, ]); } } diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 9ff11b4..086d58a 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -64,6 +64,7 @@ class ProfileController extends AbstractController if ($form->get('newPassword')->getData() !== $form->get('confirmPassword')->getData()) { $this->addFlash('error', "Les mots de passe ne correspondent pas"); return $this->render('profile/edit.html.twig', [ + 'profile' => $userConnect, 'formProfile' => $form, ]); } @@ -74,6 +75,7 @@ class ProfileController extends AbstractController if ($alreadyExists && $alreadyExists !== $profile) { $this->addFlash('error', "Ce pseudo existe déjà"); return $this->render('profile/edit.html.twig', [ + 'profile' => $userConnect, 'formProfile' => $form, ]); } @@ -83,6 +85,7 @@ class ProfileController extends AbstractController if ($alreadyExists && $alreadyExists !== $profile) { $this->addFlash('error', "Cet email existe déjà"); return $this->render('profile/edit.html.twig', [ + 'profile' => $userConnect, 'formProfile' => $form, ]); } @@ -95,6 +98,7 @@ class ProfileController extends AbstractController return $this->redirectToRoute('profile_view',['uuid' => $profile->getIdParticipant()]); } return $this->render('profile/edit.html.twig', [ + 'profile' => $userConnect, 'formProfile' => $form, ]); } catch(\Exception $e) { diff --git a/templates/main/index.html.twig b/templates/main/index.html.twig index c22a469..5d63f2f 100644 --- a/templates/main/index.html.twig +++ b/templates/main/index.html.twig @@ -8,15 +8,25 @@ {% endblock %} -{%block content %} -
-
- Logo -

Créer une nouvelle sortie

-

Vous pouvez créer une liste de voeux facilement depuis mon application web ! Cliquer sur le bouton juste en dessous pour continuer

-
-

test

+{% block content %} +
+
+ {% for sortie in sorties %} +
+
+
+
{{ sortie.nom }}
+

+ Date de début : {{ sortie.dateHeureDebut|date('d/m/Y H:i') }}
+ Durée : {{ sortie.duree }} minutes
+ Inscriptions max : {{ sortie.nbInscriptionsMax }}
+ Infos : {{ sortie.infosSortie }} +

+ Voir plus +
+
+ {% endfor %}
{% endblock %} \ No newline at end of file