feat: logging validation link

This commit is contained in:
Maël Gangloff 2024-08-12 16:57:31 +02:00
parent 2def3bbc8e
commit 628c65fd0b
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
3 changed files with 19 additions and 3 deletions

View File

@ -45,7 +45,11 @@ git clone https://github.com/maelgangloff/domain-watchdog.git
```shell
symfony server:start
```
6. Don't forget to set up workers to process the [message queue](https://symfony.com/doc/current/messenger.html)
6. Build assets:
```shell
php bin/console assets:install
```
7. Don't forget to set up workers to process the [message queue](https://symfony.com/doc/current/messenger.html)
#### Frontend
@ -96,6 +100,10 @@ git pull origin master
```shell
php bin/console cache:clear
```
4. Build assets:
```shell
php bin/console assets:install
```
### Frontend

View File

@ -82,7 +82,7 @@ class RegistrationController extends AbstractController
'username' => $user->getUserIdentifier(),
]);
$this->emailVerifier->sendEmailConfirmation('app_verify_email', $user,
$email = $this->emailVerifier->sendEmailConfirmation('app_verify_email', $user,
(new TemplatedEmail())
->from(new Address($this->mailerSenderEmail, $this->mailerSenderName))
->to($user->getEmail())
@ -91,6 +91,12 @@ class RegistrationController extends AbstractController
->htmlTemplate('emails/success/confirmation_email.html.twig')
);
$signedUrl = (string) $email->getContext()['signedUrl'];
$this->logger->notice('The validation link for user {username} is {signedUrl}', [
'username' => $user->getUserIdentifier(),
'signedUrl' => $signedUrl,
]);
return new Response(null, 201);
}

View File

@ -22,7 +22,7 @@ readonly class EmailVerifier
/**
* @throws TransportExceptionInterface
*/
public function sendEmailConfirmation(string $verifyEmailRouteName, User $user, TemplatedEmail $email): void
public function sendEmailConfirmation(string $verifyEmailRouteName, User $user, TemplatedEmail $email): TemplatedEmail
{
$signatureComponents = $this->verifyEmailHelper->generateSignature(
$verifyEmailRouteName,
@ -39,6 +39,8 @@ readonly class EmailVerifier
$email->context($context);
$this->mailer->send($email);
return $email;
}
public function handleEmailConfirmation(Request $request, User $user): void