/** * Process form * * @param AccountUser $accountUser * @return bool True on successful processing, false otherwise */ public function process(AccountUser $accountUser) { if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) { $this->form->submit($this->request); if ($this->form->isValid()) { if (!$accountUser->getId()) { if ($this->form->get('passwordGenerate')->getData()) { $generatedPassword = $this->userManager->generatePassword(10); $accountUser->setPlainPassword($generatedPassword); } if ($this->form->get('sendEmail')->getData()) { $this->userManager->sendWelcomeEmail($accountUser); } } $token = $this->securityFacade->getToken(); if ($token instanceof OrganizationContextTokenInterface) { $organization = $token->getOrganizationContext(); $accountUser->setOrganization($organization)->addOrganization($organization); } $this->userManager->updateUser($accountUser); return true; } } return false; }
/** * @param EmailBodyAdded $event */ public function linkToScope(EmailBodyAdded $event) { if ($this->securityFacade->getToken() !== null && !$this->securityFacade->isGranted('CREATE', 'entity:' . AttachmentScope::ATTACHMENT)) { return; } $email = $event->getEmail(); $entities = $this->activityListProvider->getTargetEntities($email); foreach ($entities as $entity) { if ((bool) $this->configProvider->getConfig(ClassUtils::getClass($entity))->get('auto_link_attachments')) { foreach ($email->getEmailBody()->getAttachments() as $attachment) { $this->attachmentManager->linkEmailAttachmentToTargetEntity($attachment, $entity); } } } }
/** * Find EmilUser User logged in system * * @param Email $entity - entity Email * * @return null|EmailUser */ protected function getCurrentEmailUser(Email $entity) { $user = $this->securityFacade->getToken()->getUser(); $currentOrganization = $this->securityFacade->getOrganization(); $emailUser = $this->em->getRepository('OroEmailBundle:EmailUser')->findByEmailAndOwner($entity, $user, $currentOrganization); return $emailUser; }
/** * Check ACL based on acl_resource_id, route or uri. * * @param array $options * * @return void */ protected function processAcl(array &$options = array()) { $isAllowed = self::DEFAULT_ACL_POLICY; $options['extras']['isAllowed'] = self::DEFAULT_ACL_POLICY; if (isset($options['check_access']) && $options['check_access'] === false) { return; } if ($this->hideAllForNotLoggedInUsers && !$this->securityFacade->hasLoggedUser()) { if (isset($options['extras']) && array_key_exists('showNonAuthorized', $options['extras']) && $options['extras']['showNonAuthorized']) { return; } $isAllowed = false; } elseif ($this->securityFacade->getToken() !== null) { // don't check access if it's CLI if (array_key_exists('extras', $options) && array_key_exists(self::ACL_POLICY_KEY, $options['extras'])) { $isAllowed = $options['extras'][self::ACL_POLICY_KEY]; } if (array_key_exists(self::ACL_RESOURCE_ID_KEY, $options)) { if (array_key_exists($options[self::ACL_RESOURCE_ID_KEY], $this->aclCache)) { $isAllowed = $this->aclCache[$options[self::ACL_RESOURCE_ID_KEY]]; } else { $isAllowed = $this->securityFacade->isGranted($options[self::ACL_RESOURCE_ID_KEY]); $this->aclCache[$options[self::ACL_RESOURCE_ID_KEY]] = $isAllowed; } } else { $routeInfo = $this->getRouteInfo($options); if ($routeInfo) { if (array_key_exists($routeInfo['key'], $this->aclCache)) { $isAllowed = $this->aclCache[$routeInfo['key']]; } else { $isAllowed = $this->securityFacade->isClassMethodGranted($routeInfo['controller'], $routeInfo['action']); $this->aclCache[$routeInfo['key']] = $isAllowed; } } } } $options['extras']['isAllowed'] = $isAllowed; }
/** * Find EmilUser User logged in system * * @param Email $entity - entity Email * * @return EmailUser[] */ protected function getCurrentEmailUser(Email $entity) { $user = $this->securityFacade->getToken()->getUser(); $currentOrganization = $this->securityFacade->getOrganization(); return array_merge($this->getEmailUserRepository()->findByEmailAndOwner($entity, $user, $currentOrganization), $this->getEmailUserRepository()->findByEmailForMailbox($entity)); }
/** * {@inheritdoc} */ public function isApplicable(DatagridConfiguration $config) { $className = $this->getEntityClassName($config); return !$this->isReportOrSegmentGrid($config) && $className && $this->taggableHelper->isTaggable($className) && null !== $config->offsetGetByPath(self::PROPERTY_ID_PATH) && null !== $this->securityFacade->getToken() && $this->securityFacade->isGranted('oro_tag_view'); }
/** * @return User */ protected function getUser() { return $this->securityFacade->getToken()->getUser(); }
/** * @return bool */ protected function isAccessGranted() { return null !== $this->securityFacade->getToken() && $this->securityFacade->isGranted('oro_tag_view'); }