Skip to content

Commit

Permalink
fix: config for updateLastLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
arodu committed Feb 6, 2024
1 parent 8effeb1 commit 870b864
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
// determines if registration workflow includes email validation
'validate' => true,
],
'Login' => [
'updateLastLogin' => true,
],
'Registration' => [
// determines if the register is enabled
'active' => true,
Expand Down
4 changes: 4 additions & 0 deletions src/Controller/Component/LoginComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ protected function checkSafeHost(?string $queryRedirect = null): bool
*/
protected function updateLastLogin($user)
{
if (!Configure::read('Users.Login.updateLastLogin', true)) {
return;
}

$now = \Cake\I18n\FrozenTime::now();
$user->set('last_login', $now);
$this->getController()->getUsersTable()->updateAll(
Expand Down

0 comments on commit 870b864

Please sign in to comment.