use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | ||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
class UserController extends AbstractController | class UserController extends AbstractController | ||||
{ | { | ||||
$this->em->update($user); | $this->em->update($user); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$this->addFlash('success', new TranslatableMessage('form.account_profile.message.success', [], 'admin')); | |||||
} | } | ||||
return $this->render( | return $this->render( | ||||
$this->em->update($user); | $this->em->update($user); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$this->addFlash('success', new TranslatableMessage('form.account_password.message.success', [], 'admin')); | |||||
} | } | ||||
return $this->render( | return $this->render( |
'current_password', | 'current_password', | ||||
PasswordType::class, | PasswordType::class, | ||||
[ | [ | ||||
'label' => 'form.change_password.current_password', | |||||
'label' => 'form.account_password.field.current_password', | |||||
'mapped' => false, | 'mapped' => false, | ||||
'constraints' => [ | 'constraints' => [ | ||||
new NotBlank(), | new NotBlank(), | ||||
); | ); | ||||
$builder->add( | $builder->add( | ||||
'plainPassword', | |||||
'plain_password', | |||||
RepeatedType::class, | RepeatedType::class, | ||||
[ | [ | ||||
'type' => PasswordType::class, | 'type' => PasswordType::class, | ||||
'mapped' => false, | 'mapped' => false, | ||||
'first_options' => ['label' => 'form.change_password.new_password'], | |||||
'second_options' => ['label' => 'form.change_password.new_password_repeat'], | |||||
'invalid_message' => 'Les deux mots de passe ne correspondent pas.', | |||||
'first_options' => ['label' => 'form.account_password.field.new_password'], | |||||
'second_options' => ['label' => 'form.account_password.field.new_password_repeat'], | |||||
'invalid_message' => $this->translatorAdmin->trans('form.account_password.message.invalid_passwords'), | |||||
] | ] | ||||
); | ); | ||||
seo: Référencement | seo: Référencement | ||||
form: | form: | ||||
change_password: | |||||
current_password: Mot de passe actuel | |||||
new_password: Nouveau mot de passe | |||||
new_password_repeat: Nouveau mot de passe (confirmer) | |||||
account_profile: | |||||
message: | |||||
success: Votre profil a bien été modifié | |||||
account_password: | |||||
field: | |||||
current_password: Mot de passe actuel | |||||
new_password: Nouveau mot de passe | |||||
new_password_repeat: Nouveau mot de passe (confirmer) | |||||
message: | |||||
success: Votre mot de passe a bien été modifié | |||||
invalid_passwords: Les deux mots de passe ne correspondent pas. |
return 'entity.' . $entityName . '.' . $entitySection . '.' . $name; | return 'entity.' . $entityName . '.' . $entitySection . '.' . $name; | ||||
} | } | ||||
private function trans($id, $params = [], $domain = self::DOMAIN): string | |||||
public function trans($id, $params = [], $domain = self::DOMAIN): string | |||||
{ | { | ||||
return $this->translator->trans($id, $params, $domain); | return $this->translator->trans($id, $params, $domain); | ||||
} | } |