예제 #1
0
 /**
  * switchBack
  *
  * @param User  $impersonatorUser
  * @param array $options
  *
  * @return Result
  * @throws \Exception
  */
 public function switchBack(User $impersonatorUser, $options = [])
 {
     // Get current user
     $currentUserId = $this->rcmUserService->getCurrentUser()->getId();
     $impersonatorUserId = $impersonatorUser->getId();
     $result = new Result();
     // Force login as $suUser
     $this->rcmUserService->getUserAuthService()->setIdentity($impersonatorUser);
     // log action
     $this->logAction($impersonatorUserId, $currentUserId, 'SU switched back', true);
     $result->setSuccess(true, 'SU switch back was successful');
     return $result;
 }
예제 #2
0
 /**
  * switchBack
  *
  * @param User  $impersonatorUser
  * @param array $options
  *
  * @return Result
  * @throws \Exception
  */
 public function switchBack(User $impersonatorUser, $options = [])
 {
     if (!isset($options['suUserPassword'])) {
         throw new \Exception('suUserPassword required for AuthSwitcher');
     }
     $suUserPassword = $options['suUserPassword'];
     // Get current user
     $currentUserId = $this->rcmUserService->getCurrentUser()->getId();
     $impersonatorUserId = $impersonatorUser->getId();
     $result = new Result();
     $impersonatorUser->setPassword($suUserPassword);
     $authResult = $this->rcmUserService->authenticate($impersonatorUser);
     if (!$authResult->isValid()) {
         // ERROR
         // log action
         $this->logAction($impersonatorUserId, $currentUserId, 'SU attempted to switched back, provided incorrect credentials', true);
         $result->setSuccess(false, $authResult->getMessages()[0]);
         return $result;
     }
     // log action
     $this->logAction($impersonatorUserId, $currentUserId, 'SU switched back', true);
     $result->setSuccess(true, 'SU switch back was successful');
     return $result;
 }
예제 #3
0
 /**
  * switchBack
  *
  * @param array ['suUserPassword' = null]
  *
  * @return Result
  */
 public function switchBack($options = [])
 {
     // Get current user
     $targetUser = $this->rcmUserService->getCurrentUser();
     $result = new Result();
     if (empty($targetUser)) {
         $result->setSuccess(false, 'Not logged in');
         return $result;
     }
     $impersonatorUser = $this->getImpersonatorUser($targetUser);
     if (empty($impersonatorUser)) {
         $result->setSuccess(false, 'Not in SU session');
         return $result;
     }
     return $this->switcher->switchBack($impersonatorUser, $options);
 }