From 9c5c5a94e456bba16d9ce19ea0b46977109539f4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 12 Aug 2024 10:34:00 +0900 Subject: [PATCH 1/3] fix: chain filter does not update `last_active` --- src/Filters/ChainAuth.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Filters/ChainAuth.php b/src/Filters/ChainAuth.php index 56be2c7b0..5ef0c5a6f 100644 --- a/src/Filters/ChainAuth.php +++ b/src/Filters/ChainAuth.php @@ -53,10 +53,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; } } From 549200fd0d2a7f069ca934a56e5d5f903e3be29b Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 12 Aug 2024 10:39:51 +0900 Subject: [PATCH 2/3] docs: update comment --- src/Filters/ChainAuth.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Filters/ChainAuth.php b/src/Filters/ChainAuth.php index 5ef0c5a6f..469ac0fe1 100644 --- a/src/Filters/ChainAuth.php +++ b/src/Filters/ChainAuth.php @@ -17,7 +17,6 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; -use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface; /** @@ -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 * From 566ef502f3f8f5140c750ab0640d0dd6026ade1d Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 12 Aug 2024 17:09:45 +0900 Subject: [PATCH 3/3] docs: update comment --- src/Config/Auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Auth.php b/src/Config/Auth.php index 194631726..9df36cd77 100644 --- a/src/Config/Auth.php +++ b/src/Config/Auth.php @@ -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. */