diff --git a/src/Controller/ProfilsController.php b/src/Controller/ProfilsController.php new file mode 100644 index 0000000..9e14738 --- /dev/null +++ b/src/Controller/ProfilsController.php @@ -0,0 +1,87 @@ + false], methods: ['POST','GET'])] + public function notificationSub(Request $request,UserPasswordHasherInterface $userPasswordHasher,EntityManagerInterface $entityManager,Mailer $mailer): Response + { + if(!$this->isGranted('ROLE_USER')) + return $this->render('error/forbidden.twig',[ + 'no_index' =>true + ]); + [$formProfils,$response] = $this->handleProfils($this->getUser(),$request,$entityManager,$mailer); + if(!is_null($response)){ + return $response; + } + [$formPassword,$response] = $this->handlePassword($this->getUser(),$request,$userPasswordHasher,$entityManager,$mailer); + if(!is_null($response)){ + return $response; + } + return $this->render('profis/index.twig', [ + 'formProfils' => $formProfils, + 'formPassword' => $formPassword, + 'formDelete' => '', + 'no_index' + ]); + } + + private function handleProfils(?\Symfony\Component\Security\Core\User\UserInterface $getUser, Request $request, EntityManagerInterface $entityManager, Mailer $mailer) + { + $oldEmail = $getUser->getEmail(); + $dto = new DtoProfils($getUser); + $form = $this->createForm(DtoForm::class,$dto); + $form->handleRequest($request); + if($form->isSubmitted() && $form->isValid()){ + $getUser->setEmail($dto->getEmail()); + $getUser->setUsername($dto->getUsername()); + $entityManager->persist($getUser); + $entityManager->flush(); + return [$form->createView(),$this->redirectToRoute('app_profile',['updateProfils'=>true])]; + } + return [$form->createView(),null]; + } + + private function handlePassword(?\Symfony\Component\Security\Core\User\UserInterface $getUser, Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Mailer $mailer) + { + $dto = new DtoPassword(); + $form = $this->createForm(DtoPasswordForm::class,$dto); + $form->handleRequest($request); + if($form->isSubmitted() && $form->isValid()){ + $getUser->setPassword($userPasswordHasher->hashPassword($dto->getPassword(), $getUser)); + $entityManager->persist($getUser); + $entityManager->flush(); + return [$form->createView(),$this->redirectToRoute('app_profile',['updatePassword'=>true])]; + } + return [$form->createView(),null]; + } + +} + diff --git a/src/Dto/Profils/DtoForm.php b/src/Dto/Profils/DtoForm.php new file mode 100644 index 0000000..3ef4165 --- /dev/null +++ b/src/Dto/Profils/DtoForm.php @@ -0,0 +1,34 @@ +add('email',EmailType::class,[ + 'label' => 'profils.email.label', + 'attr' => [ + 'placeholder' => 'profils.email.placeholder', + ] + ]) + ->add('username',TextType::class,[ + 'label' => 'profils.username.label', + 'attr' => [ + 'placeholder' => 'profils.username.placeholder', + ] + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefault('data_class',DtoProfils::class); + } +} diff --git a/src/Dto/Profils/DtoPassword.php b/src/Dto/Profils/DtoPassword.php new file mode 100644 index 0000000..33d1646 --- /dev/null +++ b/src/Dto/Profils/DtoPassword.php @@ -0,0 +1,24 @@ +password; + } + + /** + * @param string $password + */ + public function setPassword(string $password): void + { + $this->password = $password; + } +} diff --git a/src/Dto/Profils/DtoPasswordForm.php b/src/Dto/Profils/DtoPasswordForm.php new file mode 100644 index 0000000..9542148 --- /dev/null +++ b/src/Dto/Profils/DtoPasswordForm.php @@ -0,0 +1,27 @@ +add('password',RepeatedType::class,[ + 'type' => PasswordType::class, + 'first_options' => ['label' => 'profils.password.1','attr'=>['placeholder'=>'profils.password_holder.1']], + 'second_options' => ['label' => 'profils.password.2','attr'=>['placeholder'=>'profils.password_holder.2']], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefault('data_class',DtoPassword::class); + } +} diff --git a/src/Dto/Profils/DtoProfils.php b/src/Dto/Profils/DtoProfils.php new file mode 100644 index 0000000..d499bc1 --- /dev/null +++ b/src/Dto/Profils/DtoProfils.php @@ -0,0 +1,50 @@ +username = $account->getUsername(); + $this->email = $account->getEmail(); + } + + /** + * @return string|null + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @return string|null + */ + public function getUsername(): ?string + { + return $this->username; + } + + + /** + * @param string|null $email + */ + public function setEmail(?string $email): void + { + $this->email = $email; + } + + /** + * @param string|null $username + */ + public function setUsername(?string $username): void + { + $this->username = $username; + } +} diff --git a/templates/base.twig b/templates/base.twig index 283fc9f..b9d8eab 100644 --- a/templates/base.twig +++ b/templates/base.twig @@ -123,9 +123,18 @@
- - - + {% if app.user %} + + + + {% else %} + {# État DÉCONNECTÉ : Style neutre d'origine #} + + + + {% endif %}
+ + + + {% endif %} + {{ form_start(formProfils, {'attr': {'class': 'space-y-6'}}) }} + {{ form_row(formProfils.username) }} + {{ form_row(formProfils.email) }} + + {{ form_end(formProfils) }} + + + + {# Section Sécurité #} +
+
+

+ {{ 'form.section.security'|trans }} +

+ {% if app.request.query.has('updatePassword') %} +
+
+ {# L'ombre rigide en arrière-plan #} +
+ + {# Le contenu du message #} +
+ {# Icône de succès avec un petit effet de rebond #} +
+ +
+ +
+ + System.Notification + + + {{ 'form.section.update_password_complete'|trans }} + +
+ + {# Bouton pour fermer (optionnel) #} + +
+
+
+ {% endif %} + {{ form_start(formPassword, {'attr': {'class': 'space-y-6'}}) }} + {{ form_row(formPassword.password.first) }} + {{ form_row(formPassword.password.second) }} + + {{ form_end(formPassword) }} +
+
+ + + + + +{% endblock %} diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 894e169..9432c09 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -911,6 +911,11 @@ safespace: # Formulaire de candidature form: + # --- LABELS DES CHAMPS --- + + + # --- BOUTONS --- + choices: gender: not_specified: "Non spécifié" @@ -959,7 +964,12 @@ form: role: "Quel rôle souhaitez-vous occuper ?" section: social: "Réseaux & Portfolio" + general: "INFORMATIONS PROFIL" + security: "SÉCURITÉ & PASSWORD" + update_profils_complete: "SYNCHRONISATION DU PROFIL RÉUSSIE !" button: + save: "SAUVEGARDER LES MODIFS" + password: "UPDATE PASSWORD" submit: "Envoyer ma candidature" # Messages de succès / erreur (Optionnel pour vos contrôleurs) @@ -1143,3 +1153,41 @@ Adresse e-mail: Adresse e-mail Sujet: Sujet Téléphone (facultatif): Téléphone (facultatif) Votre message: Votre message +# translations/messages.fr.yaml + +error: + go_home: "RETOUR AU QG" + forbidden: + title: "403" + alert: "ERREUR_ACCÈS_CRITIQUE" + description: "ACCÈS REFUSÉ. CETTE ZONE EST RÉSERVÉE AUX MEMBRES AUTORISÉS OU NÉCESSITE DES PERMISSIONS SPÉCIALES." + # Si vous voulez personnaliser davantage + sub_text: "VOTRE TENTATIVE D'INTRUSION A ÉTÉ LOGUÉE DANS LE SYSTÈME." + +login: + title: "CONNEXION" + +# --- NAVIGATION DU PROFIL --- +nav: + profile: "PROFIL" + security: "SÉCURITÉ" + epage: "EPAGE" + event: "ORGANISATEUR" + admin: "PANNEAU ADMIN" + logout: "QUITTER LA SESSION" + delete: "SUPPRIMER LE COMPTE" + +# --- TITRES ET META --- +profils_title: "MON DASHBOARD" +profils_description: "GÉREZ VOS INFORMATIONS PERSONNELLES ET LA SÉCURITÉ DE VOTRE COMPTE." + +# --- SECTIONS DES FORMULAIRES --- + + +# --- PAGES D'ERREURS --- +profils.username.label: "NOM D'UTILISATEUR" +profils.email.label: "ADRESSE E-MAIL" +profils.password.1: "MOT DE PASSE" +profils.password_holder.1: "MOT DE PASSE" +profils.password.2: "CONFIRMER LE MOT DE PASSE" +profils.password_holder.2: "CONFIRMER LE MOT DE PASSE"