Skip to content

Commit

Permalink
feat: logging validation link
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Aug 12, 2024
1 parent 2def3bb commit 628c65f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
10 changes: 9 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,6 +100,10 @@ git pull origin master
```shell
php bin/console cache:clear
```
4. Build assets:
```shell
php bin/console assets:install
```
### Frontend
Expand Down
8 changes: 7 additions & 1 deletion src/Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function register(Request $request, UserPasswordHasherInterface $userPass
'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())
Expand All @@ -91,6 +91,12 @@ public function register(Request $request, UserPasswordHasherInterface $userPass
->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);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Security/EmailVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
/**
* @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,
Expand All @@ -39,6 +39,8 @@ public function sendEmailConfirmation(string $verifyEmailRouteName, User $user,
$email->context($context);

$this->mailer->send($email);

return $email;
}

public function handleEmailConfirmation(Request $request, User $user): void
Expand Down

0 comments on commit 628c65f

Please sign in to comment.