Use new authentication and hashing system

This commit is contained in:
Jannis Portmann 2021-09-04 12:59:08 +02:00
parent 10e250a1da
commit b2428f6ae3
4 changed files with 17 additions and 13 deletions

View file

@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mime\Address;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
@ -27,7 +27,7 @@ class RegistrationController extends AbstractController
}
#[Route('/register', name: 'app_register')]
public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder, GuardAuthenticatorHandler $guardHandler, AppAuthenticator $authenticator): Response
public function register(Request $request, UserPasswordHasherInterface $passwordHasher, GuardAuthenticatorHandler $guardHandler, AppAuthenticator $authenticator): Response
{
$user = new User();
$form = $this->createForm(RegistrationFormType::class, $user);
@ -36,7 +36,7 @@ class RegistrationController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
// encode the plain password
$user->setPassword(
$passwordEncoder->encodePassword(
$passwordHasher->encodePassword(
$user,
$form->get('plainPassword')->getData()
)

View file

@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use SymfonyCasts\Bundle\ResetPassword\Controller\ResetPasswordControllerTrait;
use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordExceptionInterface;
use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface;
@ -71,7 +71,7 @@ class ResetPasswordController extends AbstractController
* Validates and process the reset URL that the user clicked in their email.
*/
#[Route('/reset/{token}', name: 'app_reset_password')]
public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder, string $token = null): Response
public function reset(Request $request, UserPasswordHasherInterface $passwordHasher, string $token = null): Response
{
if ($token) {
// We store the token in session and remove it from the URL, to avoid the URL being
@ -106,7 +106,7 @@ class ResetPasswordController extends AbstractController
$this->resetPasswordHelper->removeResetRequest($token);
// Encode the plain password, and set it.
$encodedPassword = $passwordEncoder->encodePassword(
$encodedPassword = $passwordHasher->encodePassword(
$user,
$form->get('plainPassword')->getData()
);