Skip to content

Commit 3b5d6eb

Browse files
committed
refactor: allow IDE to jump from Session::checkAction() to the definition source
1 parent 6505902 commit 3b5d6eb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Authentication/Actions/Email2FA.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use CodeIgniter\HTTP\IncomingRequest;
66
use CodeIgniter\HTTP\RedirectResponse;
7+
use CodeIgniter\Shield\Authentication\Authenticators\Session;
78
use CodeIgniter\Shield\Exceptions\RuntimeException;
89
use CodeIgniter\Shield\Models\UserIdentityModel;
910

@@ -96,8 +97,11 @@ public function verify(IncomingRequest $request)
9697
{
9798
$token = $request->getPost('token');
9899

100+
/** @var Session $authenticator */
101+
$authenticator = auth('session')->getAuthenticator();
102+
99103
// Token mismatch? Let them try again...
100-
if (! auth()->checkAction('email_2fa', $token)) {
104+
if (! $authenticator->checkAction('email_2fa', $token)) {
101105
session()->setFlashdata('error', lang('Auth.invalid2FAToken'));
102106

103107
return view(setting('Auth.views')['action_email_2fa_verify']);

src/Authentication/Actions/EmailActivator.php

Lines changed: 9 additions & 3 deletions
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\Authentication\Authenticators\Session;
89
use CodeIgniter\Shield\Entities\User;
910
use CodeIgniter\Shield\Exceptions\LogicException;
1011
use CodeIgniter\Shield\Exceptions\RuntimeException;
@@ -84,18 +85,23 @@ public function verify(IncomingRequest $request)
8485
{
8586
$token = $request->getVar('token');
8687

88+
$auth = auth('session');
89+
90+
/** @var Session $authenticator */
91+
$authenticator = $auth->getAuthenticator();
92+
8793
// No match - let them try again.
88-
if (! auth()->checkAction('email_activate', $token)) {
94+
if (! $authenticator->checkAction('email_activate', $token)) {
8995
session()->setFlashdata('error', lang('Auth.invalidActivateToken'));
9096

9197
return view(setting('Auth.views')['action_email_activate_show']);
9298
}
9399

94100
/** @var User $user */
95-
$user = auth()->user();
101+
$user = $auth->user();
96102

97103
// Set the user active now
98-
auth()->activateUser($user);
104+
$auth->activateUser($user);
99105

100106
// Get our login redirect url
101107
return redirect()->to(config('Auth')->loginRedirect());

0 commit comments

Comments
 (0)