public function LoginCookie__1_0::loginUser in RESTful 7.2
Log the user in.
Parameters
object $account: The user object that was retrieved by the AuthenticationManager.
1 call to LoginCookie__1_0::loginUser()
- LoginCookie__1_0::loginAndRespondWithCookie in src/
Plugin/ resource/ LoginCookie__1_0.php - Login a user and return a JSON along with the authentication cookie.
File
- src/
Plugin/ resource/ LoginCookie__1_0.php, line 93 - Contains \Drupal\restful\Plugin\resource\LoginCookie__1_0.
Class
- LoginCookie__1_0
- Class LoginCookie__1_0 @package Drupal\restful\Plugin\resource
Namespace
Drupal\restful\Plugin\resourceCode
public function loginUser($account) {
global $user;
$this->authenticationManager
->switchUserBack();
// Explicitly allow a session to be saved, as it was disabled in
// UserSessionState::switchUser. 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);
}