mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 12:44:20 +01:00
Refine error handling
This commit is contained in:
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
@@ -53,7 +54,7 @@ final class RegistrationController extends AbstractController
|
|||||||
->subject($this->translator->trans('Please Confirm your Email'))
|
->subject($this->translator->trans('Please Confirm your Email'))
|
||||||
->htmlTemplate('backoffice/registration/confirmation_email.html.twig'),
|
->htmlTemplate('backoffice/registration/confirmation_email.html.twig'),
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (TransportExceptionInterface $e) {
|
||||||
$logger->error($e->getMessage());
|
$logger->error($e->getMessage());
|
||||||
}
|
}
|
||||||
$response = $security->login($user, 'form_login', 'main');
|
$response = $security->login($user, 'form_login', 'main');
|
||||||
|
|||||||
@@ -8,18 +8,19 @@ use App\Entity\User;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||||
use Symfony\Component\Mailer\MailerInterface;
|
use Symfony\Component\Mailer\MailerInterface;
|
||||||
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
|
|
||||||
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface;
|
use SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface;
|
||||||
|
|
||||||
class EmailVerifier
|
readonly class EmailVerifier
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly VerifyEmailHelperInterface $verifyEmailHelper,
|
private VerifyEmailHelperInterface $verifyEmailHelper,
|
||||||
private readonly MailerInterface $mailer,
|
private MailerInterface $mailer,
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/** @throws TransportExceptionInterface */
|
||||||
public function sendEmailConfirmation(string $verifyEmailRouteName, User $user, TemplatedEmail $email): void
|
public function sendEmailConfirmation(string $verifyEmailRouteName, User $user, TemplatedEmail $email): void
|
||||||
{
|
{
|
||||||
$signatureComponents = $this->verifyEmailHelper->generateSignature(
|
$signatureComponents = $this->verifyEmailHelper->generateSignature(
|
||||||
@@ -39,7 +40,6 @@ class EmailVerifier
|
|||||||
$this->mailer->send($email);
|
$this->mailer->send($email);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws VerifyEmailExceptionInterface */
|
|
||||||
public function handleEmailConfirmation(Request $request, User $user): void
|
public function handleEmailConfirmation(Request $request, User $user): void
|
||||||
{
|
{
|
||||||
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, (string) $user->getId(), (string) $user->getEmail());
|
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, (string) $user->getId(), (string) $user->getEmail());
|
||||||
|
|||||||
Reference in New Issue
Block a user