/**
  * @param UserMessage         $userMessageRepo
  * @param RcmUserService      $rcmUserService
  * @param TranslatorInterface $translator
  * @param \HTMLPurifier       $htmlPurifier
  */
 public function __construct(UserMessage $userMessageRepo, RcmUserService $rcmUserService, TranslatorInterface $translator, \HTMLPurifier $htmlPurifier)
 {
     $this->userMessageRepo = $userMessageRepo;
     $this->rcmUserService = $rcmUserService;
     $this->translator = $translator;
     $this->htmlPurifier = $htmlPurifier;
     $currentUser = $this->rcmUserService->getCurrentUser(null);
     if (!empty($currentUser)) {
         $this->currentUserId = $currentUser->getId();
     }
 }
예제 #2
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;
 }
예제 #3
0
 /**
  * @deprecated use SwitchUserAclService::currentUserIsSuAllowed
  * currentUserIsAllowed
  *
  * @return bool|mixed
  */
 public function currentUserIsAllowed()
 {
     $adminUser = $this->getCurrentImpersonatorUser();
     $targetUser = $this->rcmUserService->getCurrentUser();
     if (empty($adminUser)) {
         $adminUser = $targetUser;
     }
     return $this->isAllowed($adminUser);
 }
 /**
  * isCurrentImpersonatorUserAllowed
  *
  * @param $resourceId
  * @param $privilege
  * @param $providerId
  *
  * @return bool|mixed
  */
 public function isCurrentImpersonatorUserAllowed($resourceId, $privilege, $providerId)
 {
     $user = $this->rcmUserService->getCurrentUser();
     return $this->isImpersonatorUserAllowed($resourceId, $privilege, $providerId, $user);
 }