diff --git a/core/modules/user/src/Authentication/Provider/Cookie.php b/core/modules/user/src/Authentication/Provider/Cookie.php index fee0d3a..0ad701e 100644 --- a/core/modules/user/src/Authentication/Provider/Cookie.php +++ b/core/modules/user/src/Authentication/Provider/Cookie.php @@ -73,7 +73,15 @@ public function authenticate(Request $request) { */ protected function getUserFromSession(SessionInterface $session) { if ($uid = $session->get('uid')) { - return $this->entityManager->getStorage('user')->load($uid); + if ($user = $this->entityManager->getStorage('user')->load($uid)) { + /* @var $user \Drupal\user\UserInterface */ + if ($user->isActive()) { + return $user; + } + else { + $session->remove('uid'); + } + } } // This is an anonymous session. diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index cf05b7c..2659204 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -48,7 +48,8 @@ * entity_keys = { * "id" = "uid", * "langcode" = "langcode", - * "uuid" = "uuid" + * "uuid" = "uuid", + * "status" = "status" * }, * links = { * "canonical" = "/user/{user}", @@ -325,14 +326,14 @@ public function setLastLoginTime($timestamp) { * {@inheritdoc} */ public function isActive() { - return $this->get('status')->value == 1; + return $this->getEntityKey('status') == 1; } /** * {@inheritdoc} */ public function isBlocked() { - return $this->get('status')->value == 0; + return $this->getEntityKey('status') == 0; } /** diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 33ed45f..0e4a95f 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -749,6 +749,7 @@ function _user_cancel($edit, $account, $method) { // regenerate it because batch API uses the session ID, we will regenerate it // in _user_cancel_session_regenerate(). if ($account->id() == \Drupal::currentUser()->id()) { + \Drupal::request()->getSession()->remove('uid'); \Drupal::currentUser()->setAccount(new AnonymousUserSession()); } }