public function RestfulAuthenticationManager::switchUser in RESTful 7
Switch the user to the user authenticated by RESTful.
@link https://www.drupal.org/node/218104
1 call to RestfulAuthenticationManager::switchUser()
- RestfulAuthenticationManager::setAccount in plugins/
authentication/ RestfulAuthenticationManager.php - Setter method for the account property.
File
- plugins/
authentication/ RestfulAuthenticationManager.php, line 149 - Contains RestfulAuthenticationManager.
Class
- RestfulAuthenticationManager
- @file Contains RestfulAuthenticationManager.
Code
public function switchUser() {
global $user;
if (!restful_is_user_switched() && !$this
->getOriginalUserSession()) {
// This is the first time a user switched, and there isn't an original
// user session.
$session = drupal_save_session();
$this
->setOriginalUserSession(array(
'user' => $user,
'session' => $session,
));
// Don't allow a session to be saved. Provider that require a session to
// be saved, like the cookie provider, need to explicitly set
// drupal_save_session(TRUE).
// @see \RestfulUserLoginCookie::loginUser().
drupal_save_session(FALSE);
}
$account = $this
->getAccount();
// Set the global user.
$user = $account;
}