public function _restPutResource($id) {

    $oldUser = clone $this->model;
    $this->model->loadFromExternalSource($this->getApp()->getRequest()->getBody());

    if (!empty($this->model->password)) {
      if (strlen($this->model->password) < 6) {
        $this->getApp()->returnError(Errors::$SHORT_PASSWORD);
      }

      $this->model->passHash = Identity::passHash($this->model->password, $oldUser->salt);
      $this->model->password = NULL;

      /**
       * Deletes all sessions except for the current one for the user whose password changed
       *
       * @var $session Session
       */
      $session = call_user_func($this->sessionModelClass . '::init', $this->getApp());

      $deleteSessions = $session->findAllByField('userId', $id);
      foreach ($deleteSessions as $session) {
        if ($session->sessionId == $this->getApp()->getRequest()->session->sessionId) {
          continue;
        }
        $session->delete();
      }
    }

    if (empty($this->model->email)) {
      $this->getApp()->returnError(Errors::$EMAIL_REQUIRED);
    }

    if ($this->model->email != $oldUser->email && $this->model->findByField('email', $this->model->email)) {
      $this->getApp()->returnError(Errors::$EMAIL_EXISTS);
    }

    $this->model->created = $oldUser->created;
    $this->model->salt = $oldUser->salt;
    $this->model->lastAccessed = $oldUser->lastAccessed;
    $this->model->save();
    echo $this->model->outputJSON();
  }