maherkefi
Messages postés21Date d'inscriptionlundi 11 mars 2019StatutMembreDernière intervention13 mars 2021
-
Modifié le 27 janv. 2020 à 17:31
maherkefi
Messages postés21Date d'inscriptionlundi 11 mars 2019StatutMembreDernière intervention13 mars 2021
-
6 févr. 2020 à 09:38
Bonjour,
svp j'ai un erreur au niveau de fonction registerAction() je veux encode mon mot de passe avec la algorithme bcrypt mais quand j ajout UserPasswordEncoderInterface $encoder dans mon fonction il afficher un erreur voila la code :
<?php
namespace SocieteBundle\Controller;
use SocieteBundle\Form\UserType;
use SocieteBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
class RegistrationController extends Controller
{
public function registerAction(Request $request, UserPasswordEncoderInterface $encoder)
{
$user = new User();
$form = $this->createForm(UserType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$password = $encoder->encodePassword($user, $user->getPlainPassword());
/*$user->getPlainPassword() */
$user->setPassword( $password);
$user->setIsActive(true);
$user->addRole("ROLE_ADMIN");
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($user);
$entityManager->flush();
$this->addFlash('success', 'Votre compte à bien été enregistré.');
//return $this->redirectToRoute('login');
}
return $this->render('SocieteBundle:login:register.html.twig', ['form' => $form->createView(), 'mainNavRegistration' => true, 'title' => 'Inscription']);
}
}
Controller "SocieteBundle\Controller\RegistrationController::registerAction()" requires that you provide a value for the "$encoder" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.