Skip to content

Commit aeedcae

Browse files
committed
Add security information (IP and browser) to the password reset email
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent b62c49f commit aeedcae

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

core/Controller/LostController.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,31 @@ protected function sendEmail(string $input): void {
308308
htmlspecialchars($this->l10n->t('Click the following button to reset your password. If you have not requested the password reset, then ignore this email.')),
309309
$this->l10n->t('Click the following link to reset your password. If you have not requested the password reset, then ignore this email.')
310310
);
311-
312311
$emailTemplate->addBodyButton(
313312
htmlspecialchars($this->l10n->t('Reset your password')),
314313
$link,
315314
false
316315
);
316+
317+
if ($this->request->isUserAgent(['/Firefox\//'])) {
318+
$platform = 'Firefox';
319+
} elseif ($this->request->isUserAgent(['/Chromium\//'])) {
320+
$platform = 'Chromium';
321+
} elseif ($this->request->isUserAgent(['/Safari\//'])) {
322+
$platform = 'Safari';
323+
} elseif ($this->request->isUserAgent(['/(OPR|Opera)\//'])) {
324+
$platform = 'Opera';
325+
} elseif ($this->request->isUserAgent(['/Edg.*\//'])) {
326+
$platform = 'Edge';
327+
} elseif ($this->request->isUserAgent(['/Chrome\//'])) {
328+
$platform = 'Chrome';
329+
} else {
330+
$platform = $this->l10n->t('unknown');
331+
}
332+
$emailTemplate->addBodyText(
333+
htmlspecialchars($this->l10n->t('Security notice: This password reset was requested from following IP address and browser: %1$s (%2$s).', [ $this->request->getRemoteAddress(), $platform ]))
334+
);
335+
317336
$emailTemplate->addFooter();
318337

319338
try {

0 commit comments

Comments
 (0)