Example #1
0
 /**
  * @internal
  *
  * @param string $userUid UID of the user on the management dashboard, not a Drupal's user.
  * @param string $name
  *
  * @return Oxygen_Http_RedirectResponse
  *
  * @throws Oxygen_Exception
  */
 public function loginUser($userUid, $name)
 {
     if (strlen($name)) {
         $user = $this->userManager->findUserByName($name);
     } else {
         $user = $this->userManager->findUserById(1);
     }
     if ($user === null) {
         throw new Oxygen_Exception(Oxygen_Exception::AUTO_LOGIN_CAN_NOT_FIND_USER, array('name' => $name));
     }
     $this->sessionManager->userLogin($user);
     $options = array();
     $httpResponseCode = 302;
     $sessionId = $this->sessionManager->getSessionId();
     $this->sessionManager->registerSession($userUid, $sessionId);
     $path = 'admin/dashboard';
     $this->context->alter('drupal_goto', $path, $options, $httpResponseCode);
     $options = array('absolute' => true);
     // The 'Location' HTTP header must be absolute.
     $options['absolute'] = true;
     $url = $this->context->url($path, $options);
     $response = new Oxygen_Http_RedirectResponse($url, $httpResponseCode);
     return $response;
 }
Example #2
0
 public function execute($userUid)
 {
     $destroyed = $this->sessionManager->destroySessions($userUid);
     return array('destroyedSessions' => $destroyed);
 }