diff --git a/core/lib/Drupal/Core/Authentication/Provider/Cookie.php b/core/lib/Drupal/Core/Authentication/Provider/Cookie.php index 955fd38..9bc26c7 100644 --- a/core/lib/Drupal/Core/Authentication/Provider/Cookie.php +++ b/core/lib/Drupal/Core/Authentication/Provider/Cookie.php @@ -93,12 +93,6 @@ public function authenticate(Request $request) { // The session has expired. $user = new AnonymousUserSession(); } - // Likewise, do not update access time more than once per 180 seconds. - if ($user->isAuthenticated() && REQUEST_TIME - $user->getLastAccessedTime() > Settings::get('session_write_interval', 180)) { - /** @var \Drupal\user\UserStorageInterface $storage */ - $storage = \Drupal::entityManager()->getStorage('user'); - $storage->updateLastAccessTimestamp($user, REQUEST_TIME); - } return $user; } return NULL; diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php index eae71e7..de33340 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Session; +use Drupal\Core\Site\Settings; + /** * A proxied implementation of AccountInterface. * @@ -44,6 +46,7 @@ public function setAccount(AccountInterface $account) { $account = $account->getAccount(); } $this->account = $account; + $this->updateLastAccessedTime(); date_default_timezone_set(drupal_get_user_timezone()); } @@ -205,4 +208,16 @@ protected function loadUserEntity($account_id) { return \Drupal::entityManager()->getStorage('user')->load($account_id); } + /** + * Updates the access field of the user entity. + */ + protected function updateLastAccessedTime() { + // Likewise, do not update access time more than once per 180 seconds. + if ($this->account->isAuthenticated() && REQUEST_TIME - $this->account->getLastAccessedTime() > Settings::get('session_write_interval', 180)) { + /** @var \Drupal\user\UserStorageInterface $storage */ + $storage = \Drupal::entityManager()->getStorage('user'); + $storage->updateLastAccessTimestamp($this->account, REQUEST_TIME); + } + } + }