Skip to content

Commit 6bbdf8d

Browse files
committed
refactor: use ActionInterface::getType()
1 parent 00407a0 commit 6bbdf8d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Authentication/Authenticators/Session.php

+23-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use CodeIgniter\HTTP\IncomingRequest;
88
use CodeIgniter\HTTP\Response;
99
use CodeIgniter\I18n\Time;
10+
use CodeIgniter\Shield\Authentication\Actions\ActionInterface;
1011
use CodeIgniter\Shield\Authentication\AuthenticationException;
1112
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
1213
use CodeIgniter\Shield\Authentication\Passwords;
@@ -287,7 +288,7 @@ private function checkUserState(): void
287288

288289
$identities = $this->userIdentityModel->getIdentitiesByTypes(
289290
$this->user->getAuthId(),
290-
['email_2fa', 'email_activate']
291+
$this->getActionTypes()
291292
);
292293

293294
// If we will have more than one identity, we need to change the logic blow.
@@ -325,6 +326,27 @@ private function checkUserState(): void
325326
$this->userState = self::STATE_ANONYMOUS;
326327
}
327328

329+
/**
330+
* @return string[]
331+
*/
332+
private function getActionTypes(): array
333+
{
334+
$actions = setting('Auth.actions');
335+
$types = [];
336+
337+
foreach ($actions as $actionClass) {
338+
if ($actionClass === null) {
339+
continue;
340+
}
341+
342+
/** @var ActionInterface $action */
343+
$action = Factories::actions($actionClass); // @phpstan-ignore-line
344+
$types[] = $action->getType();
345+
}
346+
347+
return $types;
348+
}
349+
328350
public function isPending(): bool
329351
{
330352
$this->checkUserState();

0 commit comments

Comments
 (0)