Skip to content

Commit 661516f

Browse files
committed
magic-link
1 parent 76c34be commit 661516f

File tree

11 files changed

+90
-27
lines changed

11 files changed

+90
-27
lines changed

src/Controllers/MagicLinkController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use App\Controllers\BaseController;
88
use CodeIgniter\Events\Events;
9+
use CodeIgniter\HTTP\IncomingRequest;
910
use CodeIgniter\HTTP\RedirectResponse;
1011
use CodeIgniter\I18n\Time;
1112
use CodeIgniter\Shield\Authentication\Authenticators\Session;
@@ -90,11 +91,18 @@ public function loginAction()
9091
'expires' => Time::now()->addSeconds(setting('Auth.magicLinkLifetime'))->format('Y-m-d H:i:s'),
9192
]);
9293

94+
/** @var IncomingRequest $request */
95+
$request = service('request');
96+
97+
$ipAddress = $request->getIPAddress();
98+
$userAgent = (string) $request->getUserAgent();
99+
$date = Time::now()->toDateTimeString();
100+
93101
// Send the user an email with the code
94102
$email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '');
95103
$email->setTo($user->email);
96104
$email->setSubject(lang('Auth.magicLinkSubject'));
97-
$email->setMessage(view(setting('Auth.views')['magic-link-email'], ['token' => $token]));
105+
$email->setMessage(view(setting('Auth.views')['magic-link-email'], ['token' => $token, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date]));
98106

99107
if ($email->send(false) === false) {
100108
log_message('error', $email->printDebugger(['headers']));

src/Language/de/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => 'Tut mir leid. Ihr Reset-Token ist abgelaufen.',
6666

6767
// Email Globals
68-
'emailInfo' => 'Einige Informationen über die Person, die nach dem Code gefragt hat:',
68+
'emailInfo' => 'Einige Informationen über die Person:',
6969
'emailIpAddress' => 'IP Adresse:',
7070
'emailDevice' => 'Gerät:',
7171
'emailDate' => 'Datum:',

src/Language/en/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => 'Sorry. Your reset token has expired.',
6666

6767
// Email Globals
68-
'emailInfo' => 'Some information about the person who asked for the code:',
68+
'emailInfo' => 'Some information about the person:',
6969
'emailIpAddress' => 'IP Address:',
7070
'emailDevice' => 'Device:',
7171
'emailDate' => 'Date:',

src/Language/es/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => 'Lo sentimos. Tu token de reseteo ha caducado.',
6666

6767
// Email Globals
68-
'emailInfo' => 'Algunos datos sobre la persona que pidió el código:',
68+
'emailInfo' => 'Algunos datos sobre la persona:',
6969
'emailIpAddress' => 'Dirección IP:',
7070
'emailDevice' => 'Dispositivo:',
7171
'emailDate' => 'Fecha:',

src/Language/fr/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => 'Désolé. Votre jeton de réinitialisation a expiré.',
6666

6767
// Email Globals
68-
'emailInfo' => 'Quelques informations sur la personne qui a demandé le code:',
68+
'emailInfo' => 'Quelques informations sur la personne:',
6969
'emailIpAddress' => 'Adresse IP:',
7070
'emailDevice' => 'Dispositif:',
7171
'emailDate' => 'Jour:',

src/Language/id/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => 'Maaf, token setel ulang Anda sudah habis waktu.',
6666

6767
// Email Globals
68-
'emailInfo' => 'Beberapa informasi tentang seseorang yang meminta kode:',
68+
'emailInfo' => 'Beberapa informasi tentang seseorang:',
6969
'emailIpAddress' => 'Alamat IP:',
7070
'emailDevice' => 'Perangkat:',
7171
'emailDate' => 'Tanggal:',

src/Language/ja/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => '申し訳ありません。リセットトークンの有効期限が切れました。', // 'Sorry. Your reset token has expired.',
6666

6767
// Email Globals
68-
'emailInfo' => 'コードを要求した人に関する情報:',
68+
'emailInfo' => '本人に関する情報:',
6969
'emailIpAddress' => 'IPアドレス:',
7070
'emailDevice' => 'デバイス:',
7171
'emailDate' => '日時:',

src/Language/sk/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
'resetTokenExpired' => 'Prepáčte. Platnosť vášho resetovacieho tokenu vypršala.',
6666

6767
// Email Globals
68-
'emailInfo' => 'Niektoré informácie o osobe, ktorá požiadala o kód:',
68+
'emailInfo' => 'Niektoré informácie o osobe:',
6969
'emailIpAddress' => 'IP Adresa:',
7070
'emailDevice' => 'Zariadenie:',
7171
'emailDate' => 'Dátum:',
Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
32

43
<head>
5-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
4+
<meta name="x-apple-disable-message-reformatting">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
7+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
78
<title><?= lang('Auth.email2FASubject') ?></title>
89
</head>
910

1011
<body>
1112
<p><?= lang('Auth.email2FAMailBody') ?></p>
12-
<div style="text-align: center"><h1><?= $code ?></h1></div>
13+
<div style="text-align: center">
14+
<h1><?= $code ?></h1>
15+
</div>
16+
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
17+
<tbody>
18+
<tr>
19+
<td style="line-height: 20px; font-size: 20px; width: 100%; height: 20px; margin: 0;" align="left" width="100%" height="20">
20+
&#160;
21+
</td>
22+
</tr>
23+
</tbody>
24+
</table>
1325
<b><?= lang('Auth.emailInfo') ?></b>
14-
<p><?= lang('Auth.emailIpAddress') ?> <?= $ipAddress ?></p>
15-
<p><?= lang('Auth.emailDevice') ?> <?= $userAgent ?></p>
16-
<p><?= lang('Auth.emailDate') ?> <?= $date ?></p>
26+
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
27+
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
28+
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
1729
</body>
1830

1931
</html>
Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
32

43
<head>
5-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
4+
<meta name="x-apple-disable-message-reformatting">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="format-detection" content="telephone=no, date=no, address=no, email=no">
7+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
78
<title><?= lang('Auth.emailActivateSubject') ?></title>
89
</head>
910

1011
<body>
1112
<p><?= lang('Auth.emailActivateMailBody') ?></p>
12-
<div style="text-align: center"><h1><?= $code ?></h1></div>
13+
<div style="text-align: center">
14+
<h1><?= $code ?></h1>
15+
</div>
16+
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width: 100%;" width="100%">
17+
<tbody>
18+
<tr>
19+
<td style="line-height: 20px; font-size: 20px; width: 100%; height: 20px; margin: 0;" align="left" width="100%" height="20">
20+
&#160;
21+
</td>
22+
</tr>
23+
</tbody>
24+
</table>
1325
<b><?= lang('Auth.emailInfo') ?></b>
14-
<p><?= lang('Auth.emailIpAddress') ?> <?= $ipAddress ?></p>
15-
<p><?= lang('Auth.emailDevice') ?> <?= $userAgent ?></p>
16-
<p><?= lang('Auth.emailDate') ?> <?= $date ?></p>
26+
<p><?= lang('Auth.emailIpAddress') ?> <?= esc($ipAddress) ?></p>
27+
<p><?= lang('Auth.emailDevice') ?> <?= esc($userAgent) ?></p>
28+
<p><?= lang('Auth.emailDate') ?> <?= esc($date) ?></p>
1729
</body>
1830

1931
</html>

0 commit comments

Comments
 (0)