/**
  * Retrieve area front name
  *
  * @return string
  */
 public function getFrontName()
 {
     $isCustomPathUsed = (bool) (string) $this->config->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_PATH);
     if ($isCustomPathUsed) {
         return (string) $this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH);
     }
     return $this->defaultFrontName;
 }
 public function __construct(\Magento\Backend\App\ConfigInterface $backendConfig, \Symfony\Component\Yaml\Parser $yamlParser, \Magento\Framework\Filesystem $filesystem, \Magento\Config\Model\Config\Factory $configFactory)
 {
     $this->_yamlParser = $yamlParser;
     $this->_backendConfig = $backendConfig;
     $this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $this->_folderLocation = str_replace('###MAGE_BASE###', $this->_getBaseDir(), $this->_backendConfig->getValue(self::XML_SYSTEM_PATH));
     $this->_configFactory = $configFactory;
 }
 /**
  * Retrieve area front name
  *
  * @param bool $checkHost If true, verify front name is valid for this url (hostname is correct)
  * @return string|bool
  */
 public function getFrontName($checkHost = false)
 {
     if ($checkHost && !$this->isHostBackend()) {
         return false;
     }
     $isCustomPathUsed = (bool)(string)$this->config->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_PATH);
     if ($isCustomPathUsed) {
         return (string)$this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH);
     }
     return $this->defaultFrontName;
 }
Beispiel #4
0
 /**
  * Check verification result and return true if system must to show notification message
  *
  * @return bool
  */
 private function _canShowNotification()
 {
     if ($this->_cache->load(self::VERIFICATION_RESULT_CACHE_KEY)) {
         return false;
     }
     if ($this->_isFileAccessible()) {
         return true;
     }
     $adminSessionLifetime = (int) $this->_backendConfig->getValue('admin/security/session_lifetime');
     $this->_cache->save(true, self::VERIFICATION_RESULT_CACHE_KEY, [], $adminSessionLifetime);
     return false;
 }
Beispiel #5
0
 /**
  * Send email to when password is resetting
  *
  * @return $this
  */
 public function sendPasswordResetNotificationEmail()
 {
     $templateId = $this->_config->getValue(self::XML_PATH_RESET_PASSWORD_TEMPLATE);
     $transport = $this->_transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => FrontNameResolver::AREA_CODE, 'store' => Store::DEFAULT_STORE_ID])->setTemplateVars(['user' => $this, 'store' => $this->_storeManager->getStore(Store::DEFAULT_STORE_ID)])->setFrom($this->_config->getValue(self::XML_PATH_FORGOT_EMAIL_IDENTITY))->addTo($this->getEmail(), $this->getName())->getTransport();
     $transport->sendMessage();
     return $this;
 }
Beispiel #6
0
 /**
  * Send email to when password is resetting
  *
  * @return $this
  */
 public function sendPasswordResetNotificationEmail()
 {
     // Set all required params and send emails
     /** @var \Magento\Framework\Mail\TransportInterface $transport */
     $transport = $this->_transportBuilder->setTemplateIdentifier($this->_config->getValue(self::XML_PATH_RESET_PASSWORD_TEMPLATE))->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => 0])->setTemplateVars(['user' => $this, 'store' => $this->_storeManager->getStore(0)])->setFrom($this->_config->getValue(self::XML_PATH_FORGOT_EMAIL_IDENTITY))->addTo($this->getEmail(), $this->getName())->getTransport();
     $transport->sendMessage();
     return $this;
 }
 /**
  * Send user notification email
  *
  * @param string $changes
  * @param string $email
  * @return $this
  */
 protected function sendUserNotificationEmail($changes, $email = null)
 {
     if ($email === null) {
         $email = $this->getEmail();
     }
     $transport = $this->_transportBuilder->setTemplateIdentifier($this->_config->getValue(self::XML_PATH_USER_NOTIFICATION_TEMPLATE))->setTemplateModel('Magento\\Email\\Model\\BackendTemplate')->setTemplateOptions(['area' => FrontNameResolver::AREA_CODE, 'store' => Store::DEFAULT_STORE_ID])->setTemplateVars(['user' => $this, 'store' => $this->_storeManager->getStore(Store::DEFAULT_STORE_ID), 'changes' => $changes])->setFrom($this->_config->getValue(self::XML_PATH_FORGOT_EMAIL_IDENTITY))->addTo($email, $this->getName())->getTransport();
     $transport->sendMessage();
     return $this;
 }
Beispiel #8
0
 /**
  * Set session UpdatedAt to current time and update cookie expiration time
  *
  * @return void
  */
 public function prolong()
 {
     $lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
     $currentTime = time();
     $this->setUpdatedAt($currentTime);
     $cookieValue = $this->_cookie->get($this->getName());
     if ($cookieValue) {
         $this->_cookie->set($this->getName(), $cookieValue, $lifetime, $this->sessionConfig->getCookiePath(), $this->sessionConfig->getCookieDomain(), $this->sessionConfig->getCookieSecure(), $this->sessionConfig->getCookieHttpOnly());
     }
 }
Beispiel #9
0
 /**
  * Set session UpdatedAt to current time and update cookie expiration time
  *
  * @return void
  */
 public function prolong()
 {
     $lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
     $currentTime = time();
     $this->setUpdatedAt($currentTime);
     $cookieValue = $this->cookieManager->getCookie($this->getName());
     if ($cookieValue) {
         $cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration($lifetime)->setPath($this->sessionConfig->getCookiePath())->setDomain($this->sessionConfig->getCookieDomain())->setSecure($this->sessionConfig->getCookieSecure())->setHttpOnly($this->sessionConfig->getCookieHttpOnly());
         $this->cookieManager->setPublicCookie($this->getName(), $cookieValue, $cookieMetadata);
     }
 }
 /**
  * Check if user is logged in
  *
  * @return boolean
  */
 public function isLoggedIn()
 {
     $lifetime = $this->_config->getValue(self::XML_PATH_SESSION_LIFETIME);
     $currentTime = time();
     /* Validate admin session lifetime that should be more than 60 seconds */
     if ($lifetime >= 60 && $this->getUpdatedAt() < $currentTime - $lifetime) {
         return false;
     }
     if ($this->getUser() && $this->getUser()->getId()) {
         return true;
     }
     return false;
 }
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Framework\Registry $coreRegistry
  * @param \Magento\Framework\ObjectManager\ConfigInterface $config
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\ObjectManager\ConfigInterface $config, \Magento\Backend\App\ConfigInterface $backendConfig, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Module\ResourceInterface $moduleResource, \Magento\Framework\Module\ModuleList\Loader $loader, \Magento\Framework\Xml\Parser $parser, \Magento\Framework\Filesystem\Driver\File $driver, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\ProductMetadataInterface $productMetadata, \Magento\Framework\ObjectManagerInterface $objectManager)
 {
     $this->_backendConfig = $backendConfig;
     $this->moduleList = $moduleList;
     $this->moduleResource = $moduleResource;
     $this->_loader = $loader;
     $this->parser = $parser;
     $this->driver = $driver;
     $this->_objectManager = $objectManager;
     $this->urlBuilder = $urlBuilder;
     $this->productMetadata = $productMetadata;
     $this->_allowedFeedType = explode(',', $backendConfig->getValue(\Ced\DevTool\Model\Feed::XML_FEED_TYPES));
     parent::__construct($context);
 }
Beispiel #12
0
 /**
  * Get general interface locale 
  *
  * @return string
  */
 public function getGeneralLocale()
 {
     return $this->_backendConfig->getValue('general/locale/code');
 }
Beispiel #13
0
 /**
  * Retrieve customer reset password link expiration period in days
  *
  * @return int
  */
 public function getResetPasswordLinkExpirationPeriod()
 {
     return (int) $this->_config->getValue(self::XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD);
 }
Beispiel #14
0
 /**
  * Retrieve Update Frequency
  *
  * @return int
  */
 public function getFrequency()
 {
     return $this->_backendConfig->getValue(self::XML_FREQUENCY_PATH) * 3600;
 }
 /**
  * Get admin maxiumum security failures from config
  *
  * @return int
  */
 public function getMaxFailures()
 {
     return (int) $this->backendConfig->getValue('admin/security/lockout_failures');
 }
 /**
  * {@inheritdoc}
  *
  * @return string
  */
 public function getDefaultPath()
 {
     return $this->backendConfig->getValue('web/default/admin');
 }
 /**
  * @param \Magento\Backend\App\ConfigInterface $config
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct(\Magento\Backend\App\ConfigInterface $config)
 {
     $pathParts = explode('/', $config->getValue('web/default/admin'));
     $this->_parts = ['area' => isset($pathParts[0]) ? $pathParts[0] : '', 'module' => isset($pathParts[1]) ? $pathParts[1] : 'admin', 'controller' => isset($pathParts[2]) ? $pathParts[2] : 'index', 'action' => isset($pathParts[3]) ? $pathParts[3] : 'index'];
 }
Beispiel #18
0
 /**
  * Returns config value for admin captcha
  *
  * @param string $key The last part of XML_PATH_$area_CAPTCHA_ constant (case insensitive)
  * @param \Magento\Store\Model\Store $store
  * @return \Magento\Framework\App\Config\Element
  */
 public function getConfig($key, $store = null)
 {
     return $this->_backendConfig->getValue('admin/captcha/' . $key);
 }
Beispiel #19
0
 /**
  * Get max failures
  *
  * @return int
  */
 protected function getMaxFailures()
 {
     return $this->backendConfig->getValue(self::MAX_FAILURES_PATH);
 }
 /**
  * Get folder location which holds file configurations
  *
  * @return string
  */
 protected function _getAbsoluteFolderLocation()
 {
     return str_replace(self::BASE_DIR_PLACEHOLDER, $this->_directory->getAbsolutePath(), $this->_backendConfig->getValue(self::XML_SYSTEM_PATH));
 }
Beispiel #21
0
 /**
  * Get router default request path
  * @return string
  */
 protected function _getDefaultPath()
 {
     return (string) $this->_backendConfig->getValue('web/default/admin');
 }
 /**
  * @param $xmlPath
  * @return mixed
  */
 protected function _getStoreConfig($xmlPath)
 {
     return $this->_config->getValue($xmlPath);
 }