Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/customization/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ to the **app/Views/Shield/** folder.
## Customize Content

Customize the content of the view file in **app/Views/Shield/** as you like.

When customizing email templates in **app/Views/Shield/Email**, you have access to the User Entity object through the `$user` variable. Utilize `$user` to personalize the email messages according to individual user details.
2 changes: 1 addition & 1 deletion src/Authentication/Actions/Email2FA.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function handle(IncomingRequest $request)
$email->setSubject(lang('Auth.email2FASubject'));
$email->setMessage($this->view(
setting('Auth.views')['action_email_2fa_email'],
['code' => $identity->secret, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date],
['code' => $identity->secret, 'user' => $user, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date],
['debug' => false]
));

Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/Actions/EmailActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function show(): string
$email->setSubject(lang('Auth.emailActivateSubject'));
$email->setMessage($this->view(
setting('Auth.views')['action_email_activate_email'],
['code' => $code, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date],
['code' => $code, 'user' => $user, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date],
['debug' => false]
));

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/MagicLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function loginAction()
$email->setSubject(lang('Auth.magicLinkSubject'));
$email->setMessage($this->view(
setting('Auth.views')['magic-link-email'],
['token' => $token, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date],
['token' => $token, 'user' => $user, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date],
['debug' => false]
));

Expand Down
1 change: 1 addition & 0 deletions src/Views/Email/email_2fa_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</tbody>
</table>
<b><?= lang('Auth.emailInfo') ?></b>
<p><?= lang('Auth.username') ?>: <?= esc($user->username) ?></p>
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
Expand Down
1 change: 1 addition & 0 deletions src/Views/Email/email_activate_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</tbody>
</table>
<b><?= lang('Auth.emailInfo') ?></b>
<p><?= lang('Auth.username') ?>: <?= esc($user->username) ?></p>
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
Expand Down
1 change: 1 addition & 0 deletions src/Views/Email/magic_link_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</tbody>
</table>
<b><?= lang('Auth.emailInfo') ?></b>
<p><?= lang('Auth.username') ?>: <?= esc($user->username) ?></p>
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
Expand Down
6 changes: 6 additions & 0 deletions tests/Controllers/ActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public function testEmail2FAHandleSendsEmail(): void

// Should have sent an email with the code....
$this->assertStringContainsString('Your authentication code is:', service('email')->archive['body']);

// Should have included the username in the email
$this->assertStringContainsString($this->user->username, service('email')->archive['body']);
}

public function testEmail2FAVerifyFails(): void
Expand Down Expand Up @@ -248,6 +251,9 @@ public function testEmailActivateShow(): void
'!<h1>[0-9]{6}</h1>!',
service('email')->archive['body']
);

// Should have included the username in the email
$this->assertStringContainsString($this->user->username, service('email')->archive['body']);
}

public function testEmailActivateVerify(): void
Expand Down