diff --git a/app/api/module/Api/src/Domain/CommandHandler/Email/SendUserRegistered.php b/app/api/module/Api/src/Domain/CommandHandler/Email/SendUserRegistered.php index a5681738aa..3f0eadb8e2 100644 --- a/app/api/module/Api/src/Domain/CommandHandler/Email/SendUserRegistered.php +++ b/app/api/module/Api/src/Domain/CommandHandler/Email/SendUserRegistered.php @@ -7,15 +7,19 @@ namespace Dvsa\Olcs\Api\Domain\CommandHandler\Email; use Dvsa\Olcs\Api\Domain\Command\Result; +use Dvsa\Olcs\Api\Domain\ToggleAwareInterface; +use Dvsa\Olcs\Api\Domain\ToggleAwareTrait; +use Dvsa\Olcs\Api\Entity\System\FeatureToggle; use Dvsa\Olcs\Transfer\Command\CommandInterface; use Dvsa\Olcs\Api\Domain\CommandHandler\AbstractCommandHandler; /** * Send User Registered Email */ -final class SendUserRegistered extends AbstractCommandHandler implements \Dvsa\Olcs\Api\Domain\EmailAwareInterface +final class SendUserRegistered extends AbstractCommandHandler implements \Dvsa\Olcs\Api\Domain\EmailAwareInterface, ToggleAwareInterface { use \Dvsa\Olcs\Api\Domain\EmailAwareTrait; + use ToggleAwareTrait; protected $repoServiceName = 'User'; @@ -35,9 +39,14 @@ public function handleCommand(CommandInterface $command) $message->setTranslateToWelsh($user->getTranslateToWelsh()); + $template = $this->toggleService->isEnabled( + FeatureToggle::TRANSPORT_CONSULTANT_ROLE) + ? 'user-registered-tc' : 'user-registered'; + + $this->sendEmailTemplate( $message, - 'user-registered', + $template, [ 'orgName' => $user->getRelatedOrganisationName(), 'loginId' => $user->getLoginId(), diff --git a/app/api/module/Api/src/Domain/CommandHandler/User/RegisterUserSelfserve.php b/app/api/module/Api/src/Domain/CommandHandler/User/RegisterUserSelfserve.php index 3c6e75885e..7a86c11c5e 100644 --- a/app/api/module/Api/src/Domain/CommandHandler/User/RegisterUserSelfserve.php +++ b/app/api/module/Api/src/Domain/CommandHandler/User/RegisterUserSelfserve.php @@ -25,7 +25,6 @@ use Dvsa\Olcs\Transfer\Command\CommandInterface; use Dvsa\Olcs\Transfer\Command\User\RegisterUserSelfserve as RegisterUserSelfserveCommand; use Laminas\Authentication\Adapter\ValidatableAdapterInterface; -use Olcs\Logging\Log\Logger; /** * Register User Selfserve @@ -129,8 +128,8 @@ public function handleCommand(CommandInterface $command) ) ); } - } catch (\Exception $e) { - Logger::crit('Error sending email: ' . print_r($e->getMessage(), true)); + } catch (\Exception) { + // swallow any exception } $result->addId('user', $user->getId()); diff --git a/app/api/module/Email/view/email/en_GB/html/user-registered-tc.phtml b/app/api/module/Email/view/email/en_GB/html/user-registered-tc.phtml new file mode 100644 index 0000000000..345c53c50e --- /dev/null +++ b/app/api/module/Email/view/email/en_GB/html/user-registered-tc.phtml @@ -0,0 +1,11 @@ +

Hello,

+ +

You've been added to the Vehicle Operator Licensing service for escapeHtml($this->orgName); ?>.

+ +

Your username is: escapeHtml($this->loginId); ?>

+ +

You'll receive a second email with a temporary password in the next two hours. If it doesn't arrive email notification@vehicle-operator-licensing.service.gov.uk

+ +

+ Sign in +

diff --git a/app/api/module/Email/view/email/en_GB/plain/user-registered-tc.phtml b/app/api/module/Email/view/email/en_GB/plain/user-registered-tc.phtml new file mode 100644 index 0000000000..b10b7d164c --- /dev/null +++ b/app/api/module/Email/view/email/en_GB/plain/user-registered-tc.phtml @@ -0,0 +1,9 @@ +Hello, + +You've been added to the Vehicle Operator Licensing service for orgName; ?>. + +Your username is: loginId; ?>

+ +You'll receive a second email with a temporary password in the next two hours. If it doesn't arrive email notification@vehicle-operator-licensing.service.gov.uk + +Sign in at url; ?> diff --git a/app/selfserve/module/Olcs/src/Controller/UserRegistrationController.php b/app/selfserve/module/Olcs/src/Controller/UserRegistrationController.php index d376cffefd..3248f85d80 100644 --- a/app/selfserve/module/Olcs/src/Controller/UserRegistrationController.php +++ b/app/selfserve/module/Olcs/src/Controller/UserRegistrationController.php @@ -151,7 +151,6 @@ public function operatorRepresentationAction() return $this->prepareView('olcs/user-registration/index', [ 'form' => $form, - 'pageTitle' => 'operator-representation.page.title' // Set appropriate title if needed ]); }