diff --git a/.idea/sortir.iml b/.idea/sortir.iml index cf93744..0fa7baa 100644 --- a/.idea/sortir.iml +++ b/.idea/sortir.iml @@ -3,7 +3,6 @@ - diff --git a/public/img/accept-user.svg b/public/img/accept-user.svg new file mode 100644 index 0000000..108900a --- /dev/null +++ b/public/img/accept-user.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/img/deny-user.svg b/public/img/deny-user.svg new file mode 100644 index 0000000..2f27eb0 --- /dev/null +++ b/public/img/deny-user.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/img/user-able.svg b/public/img/user-able.svg new file mode 100644 index 0000000..3170fc0 --- /dev/null +++ b/public/img/user-able.svg @@ -0,0 +1,7 @@ + + + + + + plus-circle Created with Sketch Beta. + \ No newline at end of file diff --git a/public/img/user-delete.svg b/public/img/user-delete.svg new file mode 100644 index 0000000..f94dd75 --- /dev/null +++ b/public/img/user-delete.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/public/img/user-disable.svg b/public/img/user-disable.svg new file mode 100644 index 0000000..4c6dbfe --- /dev/null +++ b/public/img/user-disable.svg @@ -0,0 +1,7 @@ + + + + + + minus-circle Created with Sketch Beta. + \ No newline at end of file diff --git a/public/upload/image/profile/avatar-673f122734b9c.jpg b/public/upload/image/profile/avatar-673f122734b9c.jpg new file mode 100644 index 0000000..d3f5e22 Binary files /dev/null and b/public/upload/image/profile/avatar-673f122734b9c.jpg differ diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 086d58a..5c3580c 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -9,6 +9,7 @@ use App\Form\RegistrationFormType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Mime\MimeTypes; use Symfony\Component\Routing\Attribute\Route; use App\Repository\ParticipantRepository; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -51,6 +52,26 @@ class ProfileController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $imageFile = $form->get('image')->getData(); + if ($imageFile) { + if ($imageFile->getSize() > 1024 * 1024) { // 1MB + $this->addFlash('error', 'Votre image est trop lourde'); + return $this->render('profile/edit.html.twig', [ + 'profile' => $userConnect, + 'formProfile' => $form, + ]); + } + + $mimeTypes = new MimeTypes(); + $validMimeTypes = ['image/png', 'image/jpeg']; + $fileMimeType = $mimeTypes->guessMimeType($imageFile->getRealPath()); + if (!in_array($fileMimeType, $validMimeTypes, true)) { + $this->addFlash('error', "Veuillez insรฉrer un type d'image valide (.jpg ou .png)"); + return $this->render('profile/edit.html.twig', [ + 'profile' => $userConnect, + 'formProfile' => $form, + ]); + } + } if (($form->has('deleteImage') && $form['deleteImage']->getData()) || $imageFile) { $this->fileUploader->delete($profile->getFileName(), '/upload/image/profile'); if ($imageFile) { diff --git a/src/Form/ProfileFormType.php b/src/Form/ProfileFormType.php index 8442049..d808353 100644 --- a/src/Form/ProfileFormType.php +++ b/src/Form/ProfileFormType.php @@ -117,16 +117,6 @@ class ProfileFormType extends AbstractType 'class' => 'w-full mb-4 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500', ], 'label_attr' => ['class' => 'text-gray-700 font-bold'], - 'constraints' => [ - new File([ - 'maxSize' => '1024k', - 'mimeTypes' => [ - 'image/png', - 'image/jpeg', - ], - 'mimeTypesMessage' => 'Please upload a valid image', - ]) - ], ]) ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $profile = $event->getData(); diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index ad25c4b..7c41e12 100644 --- a/src/Form/RegistrationFormType.php +++ b/src/Form/RegistrationFormType.php @@ -90,39 +90,6 @@ class RegistrationFormType extends AbstractType ]), ], ]) - ->add('image', FileType::class, [ - 'label' => 'Image', - 'mapped' => false, - 'required' => false, - 'attr' => [ - 'class' => 'w-full mb-4 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500', - ], - 'label_attr' => ['class' => 'text-gray-700 font-bold'], - 'constraints' => [ - new File([ - 'maxSize' => '1024k', - 'mimeTypes' => [ - 'image/png', - 'image/jpeg', - ], - 'mimeTypesMessage' => 'Please upload a valid image', - ]) - ], - ]) - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { - $profile = $event->getData(); - if ($profile && $profile->getFileName()) { - $form = $event->getForm(); - $form->add('deleteImage', CheckboxType::class, [ - 'required' => false, - 'mapped' => false, - 'label' => 'Supprimer l\'image', - 'attr' => [ - 'class' => 'w-4 h-4 mb-4 border-gray-300 rounded mx-2', - ], 'label_attr' => ['class' => 'text-gray-700 font-bold px-4'] - ]); - } - }) ; } diff --git a/templates/admin/user.html.twig b/templates/admin/user.html.twig index 0e1e9b7..f54fb7d 100644 --- a/templates/admin/user.html.twig +++ b/templates/admin/user.html.twig @@ -77,11 +77,13 @@ {{ participant.roles|join(', ') }} - - - {{ participant.actif ? 'โœ”๏ธ' : 'โŒ' }} + + + Logo + + + Logo - ๐Ÿ—‘๏ธ {% endif %} @@ -132,10 +134,14 @@ - - ๐Ÿ‘Ž + + diff --git a/templates/main/base.html.twig b/templates/main/base.html.twig index 7c8285c..02e5ca9 100644 --- a/templates/main/base.html.twig +++ b/templates/main/base.html.twig @@ -19,21 +19,21 @@ {% if label == 'success' %} {% endif %} {% if label == 'error' %} {% endif %} {% if label == 'warning' %} {% endif %}