Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Config/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Auth extends BaseConfig
* --------------------------------------------------------------------
* If true, will always update the `last_active` datetime for the
* logged-in user on every page request.
* This feature only works when session/tokens filter is active.
* This feature only works when session/tokens/hmac/chain/jwt filter is active.
*
* @see https://codeigniter4.github.io/shield/quick_start_guide/using_session_auth/#protecting-pages for set filters.
*/
Expand Down
21 changes: 11 additions & 10 deletions src/Filters/ChainAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;

/**
Expand All @@ -29,14 +28,8 @@
class ChainAuth implements FilterInterface
{
/**
* Do whatever processing this filter needs to do.
* By default it should not return anything during
* normal execution. However, when an abnormal state
* is found, it should return an instance of
* CodeIgniter\HTTP\Response. If it does, script
* execution will end and that Response will be
* sent back to the client, allowing for error pages,
* redirects, etc.
* Checks authenticators in sequence to see if the user is logged in through
* either of authenticators.
*
* @param array|null $arguments
*
Expand All @@ -53,10 +46,18 @@ public function before(RequestInterface $request, $arguments = null)
$chain = config('Auth')->authenticationChain;

foreach ($chain as $alias) {
if (auth($alias)->loggedIn()) {
$auth = auth($alias);

if ($auth->loggedIn()) {
// Make sure Auth uses this Authenticator
auth()->setAuthenticator($alias);

$authenticator = $auth->getAuthenticator();

if (setting('Auth.recordActiveDate')) {
$authenticator->recordActiveDate();
}

return;
}
}
Expand Down