feat(notification): update email branding to use website type for welcome and password reset emails
This commit is contained in:
@@ -23,14 +23,15 @@ class NotificationMailService
|
|||||||
{
|
{
|
||||||
$tenant = Tenant::query()->with('websiteType')->where('codigo', $tenantCode)->firstOrFail();
|
$tenant = Tenant::query()->with('websiteType')->where('codigo', $tenantCode)->firstOrFail();
|
||||||
$user = User::query()->findOrFail($userId);
|
$user = User::query()->findOrFail($userId);
|
||||||
|
$brand = $tenant->websiteType ?? $tenant;
|
||||||
|
|
||||||
$this->mailService
|
$this->mailService
|
||||||
->forTenant($tenantCode)
|
->forTenant($tenantCode)
|
||||||
->send(
|
->send(
|
||||||
$user->email,
|
$user->email,
|
||||||
"Bienvenido a {$tenant->nombre}",
|
"Bienvenido a {$brand->nombre}",
|
||||||
view('mail.notifications.welcome', compact('tenant', 'user'))->render(),
|
view('mail.notifications.welcome', compact('brand', 'user'))->render(),
|
||||||
$tenant->websiteType ?? $tenant,
|
$brand,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,19 +77,19 @@ class NotificationMailService
|
|||||||
$recoveryUrl = $recoveryDomain === null
|
$recoveryUrl = $recoveryDomain === null
|
||||||
? null
|
? null
|
||||||
: 'https://'.$recoveryDomain.$recoveryBasePath.'/recuperar-contrasena/codigo?'.http_build_query($recoveryQuery);
|
: 'https://'.$recoveryDomain.$recoveryBasePath.'/recuperar-contrasena/codigo?'.http_build_query($recoveryQuery);
|
||||||
|
$brand = $tenant->websiteType ?? $tenant;
|
||||||
|
|
||||||
$this->mailService
|
$this->mailService
|
||||||
->forTenant($tenantCode)
|
->forTenant($tenantCode)
|
||||||
->send(
|
->send(
|
||||||
$attempt->user->email,
|
$attempt->user->email,
|
||||||
"Código para recuperar tu contraseña - {$tenant->nombre}",
|
"Código para recuperar tu contraseña - {$brand->nombre}",
|
||||||
view('mail.notifications.password-reset', [
|
view('mail.notifications.password-reset', [
|
||||||
'tenant' => $tenant,
|
|
||||||
'attempt' => $attempt,
|
'attempt' => $attempt,
|
||||||
'recoveryUrl' => $recoveryUrl,
|
'recoveryUrl' => $recoveryUrl,
|
||||||
'brand' => $tenant->websiteType ?? $tenant,
|
'brand' => $brand,
|
||||||
])->render(),
|
])->render(),
|
||||||
$tenant->websiteType ?? $tenant,
|
$brand,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
@if($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_STAFF_CREATED)
|
@if($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_STAFF_CREATED)
|
||||||
<p>
|
<p>
|
||||||
Hola {{ $attempt->user->nombre_apellido }}, creamos tu cuenta de scanner en {{ $tenant->nombre }}. Utilizá este código para crear tu contraseña y comenzar a usarla.
|
Hola {{ $attempt->user->nombre_apellido }}, creamos tu cuenta de scanner en {{ $brand->nombre }}. Utilizá este código para crear tu contraseña y comenzar a usarla.
|
||||||
</p>
|
</p>
|
||||||
@elseif($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_ACCOUNT_LOCKED)
|
@elseif($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_ACCOUNT_LOCKED)
|
||||||
<p>
|
<p>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<p>Ingresá este código en {{ $tenant->nombre }}:</p>
|
<p>Ingresá este código en {{ $brand->nombre }}:</p>
|
||||||
|
|
||||||
<div style="margin: 28px 0; padding: 20px; border: 2px solid {{ $brand->primary_color }}; border-radius: 8px; text-align: center;">
|
<div style="margin: 28px 0; padding: 20px; border: 2px solid {{ $brand->primary_color }}; border-radius: 8px; text-align: center;">
|
||||||
<span style="color: {{ $brand->primary_color }}; font-size: 36px; font-weight: 700; letter-spacing: 12px;">
|
<span style="color: {{ $brand->primary_color }}; font-size: 36px; font-weight: 700; letter-spacing: 12px;">
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<h1 style="margin: 0 0 20px;">¡Bienvenido a {{ $tenant->nombre }}!</h1>
|
<h1 style="margin: 0 0 20px;">¡Bienvenido a {{ $brand->nombre }}!</h1>
|
||||||
<p>Hola {{ $user->nombre_apellido }}, tu cuenta fue creada correctamente.</p>
|
<p>Hola {{ $user->nombre_apellido }}, tu cuenta fue creada correctamente.</p>
|
||||||
<p>Ya podés ingresar y comenzar a comprar.</p>
|
<p>Ya podés ingresar y comenzar a comprar.</p>
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ class NotificationMailServiceTest extends TestCase
|
|||||||
|
|
||||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||||
$mail->assertTo('ada@example.com');
|
$mail->assertTo('ada@example.com');
|
||||||
$mail->assertHasSubject('Bienvenido a Mail Tenant');
|
$mail->assertHasSubject('Bienvenido a OnTicket');
|
||||||
|
|
||||||
return str_contains($mail->render(), 'Ada Lovelace')
|
return str_contains($mail->render(), 'Ada Lovelace')
|
||||||
&& str_contains($mail->render(), 'Mail Tenant')
|
|
||||||
&& str_contains($mail->render(), 'OnTicket')
|
&& str_contains($mail->render(), 'OnTicket')
|
||||||
|
&& ! str_contains($mail->render(), 'Mail Tenant')
|
||||||
&& str_contains($mail->render(), 'border-top: 4px solid #ff7006');
|
&& str_contains($mail->render(), 'border-top: 4px solid #ff7006');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -100,12 +100,13 @@ class NotificationMailServiceTest extends TestCase
|
|||||||
|
|
||||||
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
Mail::assertSent(Mailable::class, function (Mailable $mail): bool {
|
||||||
$mail->assertTo('ada@example.com');
|
$mail->assertTo('ada@example.com');
|
||||||
$mail->assertHasSubject('Código para recuperar tu contraseña - Mail Tenant');
|
$mail->assertHasSubject('Código para recuperar tu contraseña - OnTicket');
|
||||||
$rendered = $mail->render();
|
$rendered = $mail->render();
|
||||||
|
|
||||||
return str_contains($rendered, '0123')
|
return str_contains($rendered, '0123')
|
||||||
&& str_contains($rendered, 'Ada Lovelace')
|
&& str_contains($rendered, 'Ada Lovelace')
|
||||||
&& str_contains($rendered, 'Mail Tenant')
|
&& str_contains($rendered, 'OnTicket')
|
||||||
|
&& ! str_contains($rendered, 'Mail Tenant')
|
||||||
&& str_contains($rendered, '#ff7006')
|
&& str_contains($rendered, '#ff7006')
|
||||||
&& ! str_contains($rendered, 'border: 2px solid #112233');
|
&& ! str_contains($rendered, 'border: 2px solid #112233');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user