You are here

protected function RestfulUserLoginCookie::loginUser in RESTful 7

Log the user.

1 call to RestfulUserLoginCookie::loginUser()
RestfulUserLoginCookie::loginAndRespondWithCookie in plugins/restful/user/login_cookie/1.0/RestfulUserLoginCookie.class.php
Login a user and return a JSON along with the authentication cookie.

File

plugins/restful/user/login_cookie/1.0/RestfulUserLoginCookie.class.php, line 43
Contains RestfulUserLoginCookie.

Class

RestfulUserLoginCookie
@file Contains RestfulUserLoginCookie.

Code

protected function loginUser() {
  global $user;
  $account = $this
    ->getAccount();

  // Explicitly allow a session to be saved, as it was disabled in
  // \RestfulAuthenticationManager::getAccount. However this resource is a
  // special one, in the sense that we want to keep the user authenticated
  // after login.
  drupal_save_session(TRUE);

  // Override the global user.
  $user = user_load($account->uid);
  $login_array = array(
    'name' => $account->name,
  );
  user_login_finalize($login_array);
}