removed encoder, set hasher

This commit is contained in:
tracer 2021-06-13 16:09:30 +02:00
parent 613605ef92
commit 99e6e4a702
1 changed files with 4 additions and 4 deletions

View File

@ -11,8 +11,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Address;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface; use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
/** /**
@ -29,16 +29,16 @@ class RegistrationController extends AbstractController
} }
#[Route('/register', name: 'app_register')] #[Route('/register', name: 'app_register')]
public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response public function register(Request $request, UserPasswordHasherInterface $passwordHasher): Response
{ {
$user = new User(); $user = new User();
$form = $this->createForm(RegistrationFormType::class, $user); $form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
// encode the plain password // hash the plain password
$user->setPassword( $user->setPassword(
$passwordEncoder->encodePassword( $passwordHasher->hashPassword(
$user, $user,
$form->get('plainPassword')->getData() $form->get('plainPassword')->getData()
) )