Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update active date only for users activated and not banned. #1184

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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 @@ -159,7 +159,7 @@ class Auth extends BaseConfig
* Record Last Active Date
* --------------------------------------------------------------------
* If true, will always update the `last_active` datetime for the
* logged-in user on every page request.
* logged-in user on every page request, provided the user is activated and not banned.
* 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
8 changes: 4 additions & 4 deletions src/Filters/HmacAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public function before(RequestInterface $request, $arguments = null)
->setJSON(['message' => lang('Auth.badToken')]);
}

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

// Block inactive users when Email Activation is enabled
$user = $authenticator->getUser();
if ($user !== null && ! $user->isActivated()) {
Expand All @@ -59,6 +55,10 @@ public function before(RequestInterface $request, $arguments = null)
->setJSON(['message' => lang('Auth.activationBlocked')]);
}

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

return $request;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Filters/SessionAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public function before(RequestInterface $request, $arguments = null)
$authenticator = auth('session')->getAuthenticator();

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

// Block inactive users when Email Activation is enabled
$user = $authenticator->getUser();

Expand All @@ -76,6 +72,10 @@ public function before(RequestInterface $request, $arguments = null)
}
}

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

return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Filters/TokenAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public function before(RequestInterface $request, $arguments = null)
->setJSON(['message' => lang('Auth.badToken')]);
}

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

// Block inactive users when Email Activation is enabled
$user = $authenticator->getUser();
if ($user !== null && ! $user->isActivated()) {
Expand All @@ -74,6 +70,10 @@ public function before(RequestInterface $request, $arguments = null)
->setStatusCode(Response::HTTP_FORBIDDEN)
->setJSON(['message' => lang('Auth.activationBlocked')]);
}

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

/**
Expand Down
Loading