Skip to content

Commit 79ed3e2

Browse files
authored
Merge pull request #119 from kenjis/add-email-null-check
Add email null check
2 parents 0a11745 + 0ea58dc commit 79ed3e2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Authentication/Actions/EmailActivator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use CodeIgniter\Exceptions\PageNotFoundException;
66
use CodeIgniter\HTTP\IncomingRequest;
77
use CodeIgniter\HTTP\RedirectResponse;
8+
use CodeIgniter\Shield\Exceptions\LogicException;
89
use CodeIgniter\Shield\Exceptions\RuntimeException;
910
use CodeIgniter\Shield\Models\UserIdentityModel;
1011

@@ -23,6 +24,13 @@ public function show(): string
2324
throw new RuntimeException('Cannot get the User.');
2425
}
2526

27+
$userEmail = $user->getAuthEmail();
28+
if ($userEmail === null) {
29+
throw new LogicException(
30+
'Email Activation needs user email address. user_id: ' . $user->getAuthId()
31+
);
32+
}
33+
2634
/** @var UserIdentityModel $identityModel */
2735
$identityModel = model(UserIdentityModel::class);
2836

@@ -44,7 +52,7 @@ public function show(): string
4452
// Send the email
4553
helper('email');
4654
$return = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? '')
47-
->setTo($user->getAuthEmail())
55+
->setTo($userEmail)
4856
->setSubject(lang('Auth.emailActivateSubject'))
4957
->setMessage(view(setting('Auth.views')['action_email_activate_email'], ['code' => $code]))
5058
->send();

0 commit comments

Comments
 (0)