feat: email bienvenue client + bouton renvoi sur fiche + lien activation

Email bienvenue (templates/emails/client_created.html.twig) :
- Envoyé automatiquement à la création du client
- Contenu : plateforme client.siteconseil.fr, identifiant email,
  bouton "Choisir mon mot de passe" avec lien app_set_password
- Compatible tous clients mail (table-based, CSS longhand)

ClientsController :
- sendWelcomeEmail() : génère le lien set_password et envoie via MailerService
- Appelé dans create() après ensureDefaultContact
- Route POST /{id}/resend-welcome : renvoie l'email si tempPassword disponible

Fiche client (show.html.twig, onglet Info) :
- Si tempPassword existe : bandeau indigo "Espace client non activé"
  + lien direct vers la page activation + bouton "Renvoyer email bienvenue"
- Si tempPassword null : bandeau vert "Espace client activé"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-04 18:53:33 +02:00
parent 619b068d9d
commit 4a9952e226
4 changed files with 139 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ use App\Controller\Admin\ClientsController;
use App\Entity\Customer;
use App\Entity\User;
use App\Repository\CustomerRepository;
use App\Service\MailerService;
use App\Service\MeilisearchService;
use App\Service\UserManagementService;
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -77,7 +78,7 @@ class ClientsControllerTest extends TestCase
$userService = $this->createStub(UserManagementService::class);
$logger = $this->createStub(LoggerInterface::class);
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(HttpClientInterface::class), 'sk_test_***');
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(HttpClientInterface::class), $this->createStub(MailerService::class), $this->createStub(Environment::class), 'sk_test_***');
$this->assertInstanceOf(Response::class, $response);
}
@@ -97,7 +98,7 @@ class ClientsControllerTest extends TestCase
$userService->method('createBaseUser')->willThrowException(new \InvalidArgumentException('Champs requis'));
$logger = $this->createStub(LoggerInterface::class);
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(HttpClientInterface::class), 'sk_test_***');
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(HttpClientInterface::class), $this->createStub(MailerService::class), $this->createStub(Environment::class), 'sk_test_***');
$this->assertInstanceOf(Response::class, $response);
}
@@ -117,7 +118,7 @@ class ClientsControllerTest extends TestCase
$userService->method('createBaseUser')->willThrowException(new \RuntimeException('DB error'));
$logger = $this->createStub(LoggerInterface::class);
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(HttpClientInterface::class), 'sk_test_***');
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(HttpClientInterface::class), $this->createStub(MailerService::class), $this->createStub(Environment::class), 'sk_test_***');
$this->assertInstanceOf(Response::class, $response);
}
@@ -290,6 +291,8 @@ class ClientsControllerTest extends TestCase
$userService,
$this->createStub(LoggerInterface::class),
$this->createStub(HttpClientInterface::class),
$this->createStub(MailerService::class),
$this->createStub(Environment::class),
'',
);
$this->assertSame(302, $response->getStatusCode());
@@ -328,6 +331,8 @@ class ClientsControllerTest extends TestCase
$userService,
$this->createStub(LoggerInterface::class),
$this->createStub(HttpClientInterface::class),
$this->createStub(MailerService::class),
$this->createStub(Environment::class),
'sk_test_***',
);
$this->assertSame(302, $response->getStatusCode());
@@ -369,6 +374,8 @@ class ClientsControllerTest extends TestCase
$userService,
$this->createStub(LoggerInterface::class),
$this->createStub(HttpClientInterface::class),
$this->createStub(MailerService::class),
$this->createStub(Environment::class),
'',
);
$this->assertSame(302, $response->getStatusCode());