diff --git a/core/lib/Drupal/Core/Session/AccountInterface.php b/core/lib/Drupal/Core/Session/AccountInterface.php
index 1dbc13c..846d6a6 100644
--- a/core/lib/Drupal/Core/Session/AccountInterface.php
+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -55,4 +55,36 @@ public function getSecureSessionId();
    */
   public function getSessionData();
 
+  /**
+   * Returns TRUE if the account is authenticated.
+   *
+   * @return bool
+   *   TRUE if the account is authenticated.
+   */
+  public function isAuthenticated();
+
+  /**
+   * Returns TRUE if the account is anonymous.
+   *
+   * @return bool
+   *   TRUE if the account is anonymous.
+   */
+  public function isAnonymous();
+
+  /**
+   * Returns the preferred language code of the account.
+   *
+   * @param $type
+   *   Optional string to define which preferred langcode should be used.
+   *   Default to 'preferred_langcode' property.
+   *   If set 'preferred_$type_langcode' is used.
+   * @param $default
+   *   Optional default language code to return if the account
+   *   has no valid language.
+   *
+   * @return string
+   *   The language code that is preferred by the account.
+   */
+  public function getPreferredLangcode($type = NULL, $default = NULL);
+
 }
diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php
index 300cd8f..aacdd8b 100644
--- a/core/lib/Drupal/Core/Session/UserSession.php
+++ b/core/lib/Drupal/Core/Session/UserSession.php
@@ -66,6 +66,20 @@ class UserSession implements AccountInterface {
   public $timestamp;
 
   /**
+   * The preferred language code of the account.
+   *
+   * @var string
+   */
+  protected $preferred_langcode;
+
+  /**
+   * The preferred language code of the account.
+   *
+   * @var string
+   */
+  protected $preferred_admin_langcode;
+
+  /**
    * Constructs a new user session.
    *
    * @param array $values
@@ -112,4 +126,37 @@ public function getSessionId() {
     return $this->sid;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->uid > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->uid == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredLangcode($type = NULL, $default = NULL) {
+    $language_list = language_list();
+    if (isset($type)) {
+      $preferred_langcode = $this->{'preferred_' . $type . '_langcode'};
+    }
+    else {
+      $preferred_langcode = $this->preferred_langcode;
+    }
+    if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
+      return $language_list[$preferred_langcode]->langcode;
+    }
+    else {
+      return $default ? $default : language_default()->langcode;
+    }
+  }
+
 }
diff --git a/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php b/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
index 584be0c..52a33ea 100644
--- a/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
+++ b/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
@@ -50,7 +50,7 @@ public function access(Route $route, Request $request) {
     // 2. the user was successfully authenticated and
     // 3. the request comes with a session cookie.
     if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE'))
-      && user_is_logged_in()
+      && $GLOBALS['user']->isAuthenticated()
       && $cookie
     ) {
       $csrf_token = $request->headers->get('X-CSRF-Token');
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
index 8690329..d1881e1 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
@@ -46,249 +46,256 @@
  */
 class User extends EntityNG implements UserInterface {
 
-  /**
-   * The user ID.
+    /**
+   * The plain data values of the contained properties.
+   *
+   * Define default values.
    *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * @var array
    */
-  public $uid;
+  protected $values = array(
+    'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
+    'preferred_langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
+    'admin_preferred_langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
+    'name' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
+    'mail' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
+    'init' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
+    'access' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 0))),
+    'login' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 0))),
+    'status' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 1))),
+  );
 
   /**
-   * The user UUID.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $uuid;
+  public function id() {
+    return $this->get('uid')->value;
+  }
 
   /**
-   * The unique user name.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $name;
+  public function getBCEntity() {
+    if (!isset($this->bcEntity)) {
+      // Initialize field definitions so that we can pass them by reference.
+      $this->getPropertyDefinitions();
+      $this->bcEntity = new UserBCDecorator($this, $this->fieldDefinitions);
+    }
+    return $this->bcEntity;
+  }
 
   /**
-   * The user's password (hashed).
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $pass;
+  public function getRoles() {
+    $roles = array();
+    foreach ($this->get('roles') as $role) {
+      $roles[] = $role->value;
+    }
+    return $roles;
+  }
 
   /**
-   * The user's email address.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $mail;
+  public function getSecureSessionId() {
+    return NULL;
+  }
 
   /**
-   * The user's default theme.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $theme;
+  public function getSessionData() {
+    return array();
+  }
 
   /**
-   * The user's signature.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $signature;
+  public function getSessionId() {
+    return NULL;
+  }
 
   /**
-   * The user's signature format.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $signature_format;
+  public function hasRole($rid) {
+    return in_array($rid, $this->getRoles());
+  }
 
   /**
-   * The timestamp when the user was created.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $created;
+  public function addRole($rid) {
+    $roles = $this->getRoles();
+    $roles[] = $rid;
+    $this->set('roles', array_unique($roles));
+  }
 
   /**
-   * The timestamp when the user last accessed the site. A value of 0 means the
-   * user has never accessed the site.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $access;
+  public function removeRole($rid) {
+    $this->set('roles', array_diff($this->getRoles(), array($rid)));
+  }
 
   /**
-   * The timestamp when the user last logged in. A value of 0 means the user has
-   * never logged in.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $login;
+  public function getPassword() {
+    return $this->get('pass')->value;
+  }
 
   /**
-   * Whether the user is active (1) or blocked (0).
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $status;
+  public function setPassword($password) {
+    $this->get('pass')->value = $password;
+  }
 
   /**
-   * The user's timezone.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $timezone;
+  public function getEmail() {
+    return $this->get('mail')->value;
+  }
 
   /**
-   * The user's langcode.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $langcode;
+  public function setEmail($mail) {
+    $this->get('mail')->value = $mail;
+  }
 
   /**
-   * The user's preferred langcode for receiving emails and viewing the site.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $preferred_langcode;
+  public function getDefaultTheme() {
+    return $this->get('theme')->value;
+  }
 
   /**
-   * The user's preferred langcode for viewing administration pages.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $preferred_admin_langcode;
+  public function getSignature() {
+    return $this->get('signature')->value;
+  }
 
   /**
-   * The email address used for initial account creation.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $init;
+  public function getSignatureFormat() {
+    return $this->get('signature_format')->value;
+  }
 
   /**
-   * The user's roles.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
+   * {@inheritdoc}
    */
-  public $roles;
+  public function getCreatedTime() {
+    return $this->get('created')->value;
+  }
 
-    /**
-   * The plain data values of the contained properties.
-   *
-   * Define default values.
-   *
-   * @var array
+  /**
+   * {@inheritdoc}
    */
-  protected $values = array(
-    'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
-    'preferred_langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
-    'admin_preffered_langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
-    'name' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
-    'mail' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
-    'init' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
-    'access' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 0))),
-    'login' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 0))),
-    'status' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 1))),
-  );
+  public function getLastAccessedTime() {
+    return $this->get('access')->value;
+  }
 
   /**
    * {@inheritdoc}
    */
-  public function id() {
-    return $this->get('uid')->value;
+  public function setLastAccessTime($timestamp) {
+    $this->get('access')->value = $timestamp;
   }
 
   /**
    * {@inheritdoc}
    */
-  protected function init() {
-    parent::init();
-    unset($this->access);
-    unset($this->created);
-    unset($this->init);
-    unset($this->login);
-    unset($this->mail);
-    unset($this->name);
-    unset($this->pass);
-    unset($this->preferred_admin_langcode);
-    unset($this->preferred_langcode);
-    unset($this->roles);
-    unset($this->signature);
-    unset($this->signature_format);
-    unset($this->status);
-    unset($this->theme);
-    unset($this->timezone);
-    unset($this->uid);
-    unset($this->uuid);
+  public function getLastLoginTime() {
+    return $this->get('login')->value;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getBCEntity() {
-    if (!isset($this->bcEntity)) {
-      // Initialize field definitions so that we can pass them by reference.
-      $this->getPropertyDefinitions();
-      $this->bcEntity = new UserBCDecorator($this, $this->fieldDefinitions);
-    }
-    return $this->bcEntity;
+  public function setLastLoginTime($timestamp) {
+    $this->get('login')->value = $timestamp;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getRoles() {
-    $roles = array();
-    foreach ($this->get('roles') as $role) {
-      $roles[] = $role->value;
-    }
-    return $roles;
+  public function isActive() {
+    return $this->get('status')->value == 1;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getSecureSessionId() {
-    return NULL;
+  public function isBlocked() {
+    return $this->get('status')->value == 0;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getSessionData() {
-    return array();
+  public function activate() {
+    $this->get('status')->value = 1;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getSessionId() {
-    return NULL;
+  public function block() {
+    $this->get('status')->value = 0;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function hasRole($rid) {
-    return in_array($rid, $this->getRoles());
+  public function getTimeZone() {
+    return $this->get('timezone')->value;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function addRole($rid) {
-    $roles = $this->getRoles();
-    $roles[] = $rid;
-    $this->set('roles', array_unique($roles));
+  function getPreferredLangcode($type = NULL, $default = NULL) {
+    $language_list = language_list();
+    if (isset($type)) {
+      $preferred_langcode = $this->get('preferred_' . $type . '_langcode')->value;
+    }
+    else {
+      $preferred_langcode = $this->get('preferred_langcode')->value;
+    }
+    if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
+      return $language_list[$preferred_langcode]->langcode;
+    }
+    else {
+      return $default ? $default : language_default()->langcode;
+    }
   }
 
   /**
    * {@inheritdoc}
    */
-  public function removeRole($rid) {
-    $this->set('roles', array_diff($this->getRoles(), array($rid)));
+  public function getInitialEmail() {
+    return $this->get('init')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->id() > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->id() == 0;
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/UserBCDecorator.php b/core/modules/user/lib/Drupal/user/UserBCDecorator.php
index f75da09..551c232 100644
--- a/core/modules/user/lib/Drupal/user/UserBCDecorator.php
+++ b/core/modules/user/lib/Drupal/user/UserBCDecorator.php
@@ -15,6 +15,12 @@
 class UserBCDecorator extends EntityBCDecorator implements UserInterface {
 
   /**
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $decorated;
+
+  /**
    * {@inheritdoc}
    */
   public function &__get($name) {
@@ -76,4 +82,151 @@ public function removeRole($rid) {
     $this->getBCEntity()->removeRole($rid);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPassword() {
+    return $this->decorated->getPassword();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPassword($password) {
+    $this->decorated->setPassword($password);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getEmail() {
+    return $this->decorated->getEmail();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setEmail($mail) {
+    $this->decorated->setEmail($mail);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultTheme() {
+    return $this->decorated->getDefaultTheme();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignature() {
+    return $this->decorated->getDefaultTheme();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignatureFormat() {
+    return $this->decorated->getSignatureFormat();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCreatedTime() {
+    return $this->decorated->getCreatedTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastAccessedTime() {
+    return $this->decorated->getLastAccessedTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastAccessTime($timestamp) {
+    $this->decorated->setLastAccessTime($timestamp);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastLoginTime() {
+    return $this->decorated->getLastLoginTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastLoginTime($timestamp) {
+    $this->decorated->setLastLoginTime($timestamp);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isActive() {
+    $this->decorated->isActive();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isBlocked() {
+    return $this->decorated->isBlocked();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function activate() {
+    $this->decorated->activate();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function block() {
+    $this->decorated->block();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTimeZone() {
+    return $this->decorated->getTimeZone();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPreferredLangcode($type = NULL, $default = NULL) {
+    return $this->decorated->getPreferredLangcode();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getInitialEmail() {
+    return $this->decorated->getInitialEmail();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->decorated->id() > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->decorated->id() == 0;
+  }
+
 }
diff --git a/core/modules/user/lib/Drupal/user/UserInterface.php b/core/modules/user/lib/Drupal/user/UserInterface.php
index 4dc1481..59a13a8 100644
--- a/core/modules/user/lib/Drupal/user/UserInterface.php
+++ b/core/modules/user/lib/Drupal/user/UserInterface.php
@@ -50,4 +50,163 @@ public function addRole($rid);
    */
   public function removeRole($rid);
 
+  /**
+   * Returns the hashed password.
+   *
+   * @return string
+   *   The hashed password.
+   */
+  public function getPassword();
+
+  /**
+   * Sets the user password.
+   *
+   * @param string $password
+   *   The new unhashed password.
+   */
+  public function setPassword($password);
+
+  /**
+   * Returns the e-mail address of the user.
+   *
+   * @return string
+   *   The e-mail address.
+   */
+  public function getEmail();
+
+  /**
+   * Sets the e-mail address of the user.
+   *
+   * @param string $mail
+   *   The new e-mail address of the user.
+   */
+  public function setEmail($mail);
+
+  /**
+   * Returns the default theme of the user.
+   *
+   * @return string
+   *   Name of the theme.
+   */
+  public function getDefaultTheme();
+
+  /**
+   * Returns the user signature.
+   *
+   * @todo: Convert this to a field.
+   *
+   * @return string
+   *   The signature text.
+   */
+  public function getSignature();
+
+  /**
+   * Returns the signature format.
+   *
+   * @return string
+   *   Name of the filter format.
+   */
+  public function getSignatureFormat();
+
+  /**
+   * Returns the creation time of the user as a UNIX timestamp.
+   *
+   * @return int
+   *   Timestamp of the creation date.
+   *
+   */
+  public function getCreatedTime();
+
+  /**
+   * The timestamp when the user last accessed the site.
+   *
+   * A value of 0 means the user has never accessed the site.
+   *
+   * @return int
+   *   Timestamp of the last access.
+   */
+  public function getLastAccessedTime();
+
+  /**
+   * Sets the UNIX timestamp when the user last accessed the site..
+   *
+   * @param int $timestamp
+   *   Timestamp of the last access.
+   */
+  public function setLastAccessTime($timestamp);
+
+  /**
+   * Returns the UNIX timestamp when the user last logged in.
+   *
+   * @return int
+   *   Timestamp of the last login time.
+   */
+  public function getLastLoginTime();
+
+  /**
+   * Sets the UNIX timestamp when the user last logged in.
+   *
+   * @param int $timestamp
+   *   Timestamp of the last login time.
+   */
+  public function setLastLoginTime($timestamp);
+
+  /**
+   * Returns TRUE if the user is active.
+   *
+   * @return bool
+   *   TRUE if the user is active, false otherwise.
+   */
+  public function isActive();
+
+  /**
+   * Returns TRUE if the user is blocked.
+   *
+   * @return bool
+   *   TRUE if the user is blocked, false otherwise.
+   */
+  public function isBlocked();
+
+  /**
+   * Activates the user.
+   */
+  public function activate();
+
+  /**
+   * Blocks the user.
+   */
+  public function block();
+
+  /**
+   * Returns the timezone of the user.
+   *
+   * @return string
+   *   Name of the timezone.
+   */
+  public function getTimeZone();
+
+  /**
+   * Returns the preferred language code of the user.
+   *
+   * @param $type
+   *   Optional string to define which preferred langcode should be used.
+   *   Default to 'preferred_langcode' property.
+   *   If set 'preferred_$type_langcode' is used.
+   * @param $default
+   *   Optional default language code to return if the account
+   *   has no valid language.
+   *
+   * @return string
+   *   The language code that is preferred by the user.
+   */
+  public function getPreferredLangcode($type = NULL, $default = NULL);
+
+  /**
+   * Returns the e-mail that was used when the user was registered.
+   *
+   * @return string
+   *   Initial e-mail address of the user.
+   */
+  public function getInitialEmail();
+
 }
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 1c7633d..7666ed2 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -410,7 +410,8 @@ function user_password($length = 10) {
  * Determine the permissions for one or more roles.
  *
  * @param $roles
- *   An array whose values are the role IDs of interest, such as $user->roles.
+ *   An array whose values are the role IDs of interest, such as
+ *   \Drupal\Core\Session\AccountInterface::getRoles().
  *
  * @return
  *   An array indexed by role ID. Each value is an array whose keys are the
@@ -472,11 +473,8 @@ function user_access($string, AccountInterface $account = NULL) {
     $account = $user;
   }
 
-  // Make sure we are working with the BC decorator.
-  $account = $account instanceof User ? $account->getBCEntity() : $account;
-
   // User #1 has all privileges:
-  if ($account->uid == 1) {
+  if ($account->id() == 1) {
     return TRUE;
   }
 
@@ -488,17 +486,17 @@ function user_access($string, AccountInterface $account = NULL) {
     $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
   }
   $perm = &$drupal_static_fast['perm'];
-  if (!isset($perm[$account->uid])) {
+  if (!isset($perm[$account->id()])) {
     $role_permissions = user_role_permissions($account->getRoles());
 
     $perms = array();
     foreach ($role_permissions as $one_role) {
       $perms += $one_role;
     }
-    $perm[$account->uid] = $perms;
+    $perm[$account->id()] = $perms;
   }
 
-  return isset($perm[$account->uid][$string]);
+  return isset($perm[$account->id()][$string]);
 }
 
 /**
@@ -599,10 +597,10 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
   foreach ($accounts as $account) {
     $result = array(
       'title' => user_format_name($account),
-      'link' => url('user/' . $account->uid, array('absolute' => TRUE)),
+      'link' => url('user/' . $account->id(), array('absolute' => TRUE)),
     );
     if (user_access('administer users')) {
-      $result['title'] .= ' (' . $account->mail . ')';
+      $result['title'] .= ' (' . $account->getEmail() . ')';
     }
     $results[] = $result;
   }
@@ -720,7 +718,7 @@ function user_template_preprocess_default_variables_alter(&$variables) {
   unset($variables['user']->pass, $variables['user']->sid, $variables['user']->ssid);
 
   $variables['is_admin'] = user_access('access administration pages');
-  $variables['logged_in'] = ($user->uid > 0);
+  $variables['logged_in'] = $user->isAuthenticated();
 }
 
 /**
@@ -739,14 +737,9 @@ function template_preprocess_username(&$variables) {
   }
 
   $variables['extra'] = '';
-  if (empty($account->uid)) {
-   $variables['uid'] = 0;
-   if (theme_get_setting('features.comment_user_verification')) {
-     $variables['extra'] = ' (' . t('not verified') . ')';
-   }
-  }
-  else {
-    $variables['uid'] = (int) $account->uid;
+  $variables['uid'] = $account->id();
+  if ($account->id() && theme_get_setting('features.comment_user_verification')) {
+    $variables['extra'] = ' (' . t('not verified') . ')';
   }
 
   // Set the name to a formatted name that is safe for printing and
@@ -847,7 +840,7 @@ function theme_username($variables) {
  */
 function user_is_anonymous() {
   // Menu administrators can see items for anonymous when administering.
-  return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']);
+  return $GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin']);
 }
 
 /**
@@ -855,9 +848,11 @@ function user_is_anonymous() {
  *
  * @return bool
  *   TRUE if the user is logged in, FALSE if the user is anonymous.
+ *
+ * @deprecated Use \Drupal\Core\Session\UserSession::isAuthenticated().
  */
 function user_is_logged_in() {
-  return (bool) $GLOBALS['user']->uid;
+  return $GLOBALS['user']->isAuthenticated();
 }
 
 /**
@@ -1065,7 +1060,7 @@ function user_menu() {
 function user_menu_site_status_alter(&$menu_site_status, $path) {
   if ($menu_site_status == MENU_SITE_OFFLINE) {
     // If the site is offline, log out unprivileged users.
-    if (user_is_logged_in() && !user_access('access site in maintenance mode')) {
+    if ($GLOBALS['user']->isAuthenticated() && !user_access('access site in maintenance mode')) {
       module_load_include('pages.inc', 'user', 'user');
       user_logout();
     }
@@ -1089,14 +1084,14 @@ function user_menu_site_status_alter(&$menu_site_status, $path) {
       }
     }
   }
-  if (user_is_logged_in()) {
+  if ($GLOBALS['user']->isAuthenticated()) {
     if ($path == 'user/login') {
       // If user is logged in, redirect to 'user' instead of giving 403.
       drupal_goto('user');
     }
     if ($path == 'user/register') {
       // Authenticated user should be redirected to user edit page.
-      drupal_goto('user/' . $GLOBALS['user']->uid . '/edit');
+      drupal_goto('user/' . $GLOBALS['user']->id() . '/edit');
     }
   }
 }
@@ -1137,7 +1132,7 @@ function user_menu_breadcrumb_alter(&$active_trail, $item) {
 function user_menu_link_load($menu_links) {
   // Hide the "User account" link for anonymous users.
   foreach ($menu_links as $link) {
-    if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->uid) {
+    if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->id()) {
       $link['hidden'] = 1;
     }
   }
@@ -1183,7 +1178,7 @@ function user_uid_only_optional_to_arg($arg) {
  */
 function user_uid_optional_load($uid = NULL) {
   if (!isset($uid)) {
-    $uid = $GLOBALS['user']->uid;
+    $uid = $GLOBALS['user']->id();
   }
   return user_load($uid);
 }
@@ -1197,7 +1192,7 @@ function user_uid_optional_to_arg($arg) {
   // Give back the current user uid when called from eg. tracker, aka.
   // with an empty arg. Also use the current user uid when called from
   // the menu with a % for the current account link.
-  return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
+  return empty($arg) || $arg == '%' ? $GLOBALS['user']->id() : $arg;
 }
 
 /**
@@ -1207,7 +1202,7 @@ function user_uid_optional_to_arg($arg) {
  * authenticated users are expected to see "My account".
  */
 function user_menu_title() {
-  if (!user_is_logged_in()) {
+  if ($GLOBALS['user']->isAnonymous()) {
     switch (current_path()) {
       case 'user' :
       case 'user/login' :
@@ -1326,13 +1321,13 @@ function user_login_authenticate_validate($form, &$form_state) {
       if ($flood_config->get('uid_only')) {
         // Register flood events based on the uid only, so they apply for any
         // IP address. This is the most secure option.
-        $identifier = $account->uid;
+        $identifier = $account->id();
       }
       else {
         // The default identifier is a combination of uid and IP address. This
         // is less secure but more resistant to denial-of-service attacks that
         // could lock out all users with public user names.
-        $identifier = $account->uid . '-' . Drupal::request()->getClientIP();
+        $identifier = $account->id() . '-' . Drupal::request()->getClientIP();
       }
       $form_state['flood_control_user_identifier'] = $identifier;
 
@@ -1413,11 +1408,11 @@ function user_authenticate($name, $password) {
       $password_hasher = drupal_container()->get('password');
       if ($password_hasher->check($password, $account)) {
         // Successful authentication.
-        $uid = $account->uid;
+        $uid = $account->id();
 
         // Update user to new password scheme if needed.
         if ($password_hasher->userNeedsNewHash($account)) {
-          $account->pass = $password;
+          $account->setPassword($password);
           $account->save();
         }
       }
@@ -1439,13 +1434,13 @@ function user_authenticate($name, $password) {
  */
 function user_login_finalize(&$edit = array()) {
   global $user;
-  watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
+  watchdog('user', 'Session opened for %name.', array('%name' => $user->label()));
   // Update the user table timestamp noting user has logged in.
   // This is also used to invalidate one-time login links.
-  $user->login = REQUEST_TIME;
+  $user->setLastLoginTime(REQUEST_TIME);
   db_update('users')
-    ->fields(array('login' => $user->login))
-    ->condition('uid', $user->uid)
+    ->fields(array('login' => $user->getLastLoginTime()))
+    ->condition('uid', $user->id())
     ->execute();
 
   // Regenerate the session ID to prevent against session fixation attacks.
@@ -1464,7 +1459,7 @@ function user_login_finalize(&$edit = array()) {
 function user_login_form_submit($form, &$form_state) {
   global $user;
   $user = user_load($form_state['uid']);
-  $form_state['redirect'] = 'user/' . $user->uid;
+  $form_state['redirect'] = 'user/' . $user->id();
 
   user_login_finalize($form_state);
 }
@@ -1506,9 +1501,9 @@ function user_user_logout($account) {
  */
 function user_pass_reset_url($account, $options = array()) {
   $timestamp = REQUEST_TIME;
-  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
+  $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
   $url_options = array('absolute' => TRUE, 'language' => language_load($langcode));
-  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
+  return url("user/reset/" . $account->id() . "/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options);
 }
 
 /**
@@ -1534,9 +1529,9 @@ function user_pass_reset_url($account, $options = array()) {
  */
 function user_cancel_url($account, $options = array()) {
   $timestamp = REQUEST_TIME;
-  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
+  $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
   $url_options = array('absolute' => TRUE, 'language' => language_load($langcode));
-  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
+  return url("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->login), $url_options);
 }
 
 /**
@@ -1615,7 +1610,7 @@ function user_cancel($edit, $uid, $method) {
   );
 
   // After cancelling account, ensure that user is logged out.
-  if ($account->uid == $user->uid) {
+  if ($account->id() == $user->id()) {
     // Batch API stores data in the session, so use the finished operation to
     // manipulate the current user's session id.
     $batch['finished'] = '_user_cancel_session_regenerate';
@@ -1658,7 +1653,7 @@ function _user_cancel($edit, $account, $method) {
       if (!empty($edit['user_cancel_notify'])) {
         _user_mail_notify('status_canceled', $account);
       }
-      user_delete($account->uid);
+      $account->delete();
       drupal_set_message(t('%name has been deleted.', array('%name' => $account->name)));
       watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
       break;
@@ -1668,7 +1663,7 @@ function _user_cancel($edit, $account, $method) {
   // their session though, as we might have information in it, and we can't
   // regenerate it because batch API uses the session ID, we will regenerate it
   // in _user_cancel_session_regenerate().
-  if ($account->uid == $user->uid) {
+  if ($account->id() == $user->id()) {
     $user = drupal_anonymous_user();
   }
 
@@ -2067,7 +2062,7 @@ function user_multiple_cancel_confirm($form, &$form_state) {
   $edit = $form_state['input'];
 
   // Retrieve the accounts to be canceled from the temp store.
-  $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($GLOBALS['user']->uid);
+  $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($GLOBALS['user']->id());
   $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
   foreach ($accounts as $account) {
     $uid = $account->id();
@@ -2135,7 +2130,7 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
   global $user;
 
   // Clear out the accounts from the temp store.
-  Drupal::service('user.tempstore')->get('user_user_operations_cancel')->delete($user->uid);
+  Drupal::service('user.tempstore')->get('user_user_operations_cancel')->delete($user->id());
   if ($form_state['values']['confirm']) {
     foreach ($form_state['values']['accounts'] as $uid => $value) {
       // Prevent programmatic form submissions from cancelling user 1.
@@ -2143,12 +2138,12 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
         continue;
       }
       // Prevent user administrators from deleting themselves without confirmation.
-      if ($uid == $user->uid) {
+      if ($uid == $user->id()) {
         $admin_form_state = $form_state;
         unset($admin_form_state['values']['user_cancel_confirm']);
         // The $user global is not a complete user entity, so load the full
         // entity.
-        $admin_form_state['values']['_account'] = user_load($user->uid);
+        $admin_form_state['values']['_account'] = user_load($user->id());
         user_cancel_confirm_form_submit(array(), $admin_form_state);
       }
       else {
@@ -2336,7 +2331,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) {
   $notify = config('user.settings')->get('notify.' . $op);
   if ($notify || ($op != 'status_canceled' && $op != 'status_blocked')) {
     $params['account'] = $account;
-    $langcode = $langcode ? $langcode : user_preferred_langcode($account);
+    $langcode = $langcode ? $langcode : $account->getPreferredLangcode();
     // Get the custom site notification email to use as the from email address
     // if it has been set.
     $site_mail = config('system.site')->get('mail_notification');
@@ -2589,7 +2584,7 @@ function user_toolbar() {
   global $user;
 
   // Add logout & user account links or login link.
-  if ($user->uid) {
+  if ($user->isAuthenticated()) {
     $links = array(
       'account' => array(
         'title' => t('View profile'),
@@ -2601,7 +2596,7 @@ function user_toolbar() {
       ),
       'account_edit' => array(
         'title' => t('Edit profile'),
-        'href' => 'user/' . $user->uid . '/edit',
+        'href' => 'user/' . $user->id() . '/edit',
         'html' => TRUE,
         'attributes' => array(
           'title' => t('Edit user account'),
