• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP App\ConfigInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Backend\App\ConfigInterface的典型用法代码示例。如果您正苦于以下问题:PHP ConfigInterface类的具体用法?PHP ConfigInterface怎么用?PHP ConfigInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ConfigInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 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;
 }
开发者ID:jzahedieh,项目名称:Magento2-FileConfigurator,代码行数:8,代码来源:Yaml.php


示例2: __construct

 /**
  * @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);
 }
开发者ID:dineshmalekar,项目名称:Magento2-Developer-Debug-Tool,代码行数:19,代码来源:Feed.php


示例3: __construct

 /**
  * @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'];
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:DefaultPath.php


示例4: testCheckUpdate

 /**
  * @dataProvider checkUpdateDataProvider
  * @param bool $callInbox
  * @param string $curlRequest
  */
 public function testCheckUpdate($callInbox, $curlRequest)
 {
     $mockName = 'Test Product Name';
     $mockVersion = '0.0.0';
     $mockEdition = 'Test Edition';
     $mockUrl = 'http://test-url';
     $this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
     $this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
     $this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
     $configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
     $lastUpdate = 0;
     $this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
     $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
     $this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
     $this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
     $this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
     $this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
     $this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
     $this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
     if ($callInbox) {
         $this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
         $this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
     } else {
         $this->inboxFactory->expects($this->never())->method('create');
         $this->inboxModel->expects($this->never())->method('parse');
     }
     $this->feed->checkUpdate();
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:34,代码来源:FeedTest.php


示例5: getFrontName

 /**
  * 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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:FrontNameResolver.php


示例6: getFrontName

 /**
  * 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;
 }
开发者ID:razbakov,项目名称:magento2,代码行数:17,代码来源:FrontNameResolver.php


示例7: _canShowNotification

 /**
  * 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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Security.php


示例8: authenticate

    /**
     * Authenticate user name and password and save loaded record
     *
     * @param string $username
     * @param string $password
     * @return bool
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function authenticate($username, $password)
    {
        $config = $this->_config->isSetFlag('admin/security/use_case_sensitive_login');
        $result = false;

        try {
            $this->_eventManager->dispatch(
                'admin_user_authenticate_before',
                ['username' => $username, 'user' => $this]
            );
            $this->loadByUsername($username);
            $sensitive = $config ? $username == $this->getUsername() : true;
            if ($sensitive && $this->getId()) {
                $result = $this->verifyIdentity($password);
            }

            $this->_eventManager->dispatch(
                'admin_user_authenticate_after',
                ['username' => $username, 'password' => $password, 'user' => $this, 'result' => $result]
            );
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
            $this->unsetData();
            throw $e;
        }

        if (!$result) {
            $this->unsetData();
        }
        return $result;
    }
开发者ID:razbakov,项目名称:magento2,代码行数:38,代码来源:User.php


示例9: testAuthenticateException

 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @return void
  */
 public function testAuthenticateException()
 {
     $username = 'username';
     $password = 'password';
     $config = 'config';
     $this->configMock->expects($this->once())->method('isSetFlag')->with('admin/security/use_case_sensitive_login')->willReturn($config);
     $this->eventManagerMock->expects($this->any())->method('dispatch');
     $this->resourceMock->expects($this->once())->method('loadByUsername')->willThrowException(new \Magento\Framework\Exception\LocalizedException(__()));
     $this->model->authenticate($username, $password);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:UserTest.php


示例10: prolong

 /**
  * 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());
     }
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:15,代码来源:Session.php


示例11: prolong

 /**
  * 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);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Session.php


示例12: testTrackAdminPassword

 public function testTrackAdminPassword()
 {
     $newPW = "mYn3wpassw0rd";
     $uid = 123;
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getObject'])->getMock();
     /** @var \Magento\User\Model\User|\PHPUnit_Framework_MockObject_MockObject $userMock */
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getPassword', 'getForceNewPassword'])->getMock();
     $eventObserverMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
     $eventMock->expects($this->once())->method('getObject')->willReturn($userMock);
     $userMock->expects($this->once())->method('getId')->willReturn($uid);
     $userMock->expects($this->once())->method('getPassword')->willReturn($newPW);
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     $userMock->expects($this->once())->method('getForceNewPassword')->willReturn(false);
     /** @var \Magento\Framework\Message\Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
     $collectionMock = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->managerInterfaceMock->expects($this->once())->method('getMessages')->willReturn($collectionMock);
     $this->authSessionMock->expects($this->once())->method('unsPciAdminUserIsPasswordExpired')->willReturn(null);
     $this->model->execute($eventObserverMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:22,代码来源:TrackAdminNewPasswordObserverTest.php


示例13: isLoggedIn

 /**
  * 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;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:18,代码来源:Session.php


示例14: testCustomerHasFailedMaxNumberOfAttempts

 /**
  * @return void
  */
 public function testCustomerHasFailedMaxNumberOfAttempts()
 {
     $customerId = 1;
     $date = new \DateTime();
     $date->modify('-500 second');
     $formattedDate = $date->format('Y-m-d H:i:s');
     $this->backendConfigMock->expects($this->exactly(2))->method('getValue')->withConsecutive([\Magento\Customer\Helper\AccountManagement::LOCKOUT_THRESHOLD_PATH], [\Magento\Customer\Helper\AccountManagement::MAX_FAILURES_PATH])->willReturnOnConsecutiveCalls(10, 5);
     $this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
     $this->customerSecure->expects($this->once())->method('getFailuresNum')->willReturn(5);
     $this->customerSecure->expects($this->once())->method('getFirstFailure')->willReturn($formattedDate);
     $this->customerSecure->expects($this->once())->method('setLockExpires');
     $this->customerSecure->expects($this->once())->method('setFailuresNum');
     $this->helper->processCustomerLockoutData($customerId);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:17,代码来源:AccountManagementTest.php


示例15: testForceAdminPasswordChange

 public function testForceAdminPasswordChange()
 {
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getControllerAction', 'getRequest'])->getMock();
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     $this->authSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
     /** @var \Magento\Framework\App\Action\Action $controllerMock */
     $controllerMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\AbstractAction')->disableOriginalConstructor()->setMethods(['getRedirect', 'getRequest'])->getMockForAbstractClass();
     /** @var \Magento\Framework\App\RequestInterface $requestMock */
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getFullActionName', 'setDispatched'])->getMockForAbstractClass();
     $eventMock->expects($this->once())->method('getControllerAction')->willReturn($controllerMock);
     $eventMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $this->authSessionMock->expects($this->once())->method('getPciAdminUserIsPasswordExpired')->willReturn(true);
     $requestMock->expects($this->once())->method('getFullActionName')->willReturn('not_in_array');
     $this->authSessionMock->expects($this->once())->method('clearStorage');
     $this->sessionMock->expects($this->once())->method('clearStorage');
     $this->managerInterfaceMock->expects($this->once())->method('addErrorMessage');
     $controllerMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $requestMock->expects($this->once())->method('setDispatched')->willReturn(false);
     $this->model->execute($eventObserverMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:ForceAdminPasswordChangeObserverTest.php


示例16: testSendPasswordResetConfirmationEmail

 public function testSendPasswordResetConfirmationEmail()
 {
     $storeId = 0;
     $email = '[email protected]';
     $firstName = 'Foo';
     $lastName = 'Bar';
     $this->_model->setEmail($email);
     $this->_model->setFirstname($firstName);
     $this->_model->setLastname($lastName);
     $this->_configMock->expects($this->at(0))->method('getValue')->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_TEMPLATE)->will($this->returnValue('templateId'));
     $this->_configMock->expects($this->at(1))->method('getValue')->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_IDENTITY)->will($this->returnValue('sender'));
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateOptions')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['user' => $this->_model, 'store' => $this->_storetMock])->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('addTo')->with($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName))->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setFrom')->with('sender')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with('templateId')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transportMock));
     $this->_transportMock->expects($this->once())->method('sendMessage');
     $this->_storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($this->_storetMock));
     $this->assertInstanceOf('\\Magento\\User\\Model\\User', $this->_model->sendPasswordResetConfirmationEmail());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:UserTest.php


示例17: testValidateCustomerPassword

 /**
  * @param bool $result
  * @dataProvider validateCustomerPassword
  */
 public function testValidateCustomerPassword($result)
 {
     $customerId = 7;
     $password = '1234567';
     $hash = '1b2af329dd0';
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->willReturn($customerMock);
     $this->customerSecure->expects($this->any())->method('getId')->willReturn($customerId);
     $this->customerSecure->expects($this->once())->method('getPasswordHash')->willReturn($hash);
     $this->customerRegistryMock->expects($this->any())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
     $this->encryptorMock->expects($this->once())->method('validateHash')->with($password, $hash)->willReturn($result);
     if ($result) {
         $this->assertTrue($this->authentication->authenticate($customerId, $password));
     } else {
         $this->backendConfigMock->expects($this->exactly(2))->method('getValue')->withConsecutive([\Magento\Customer\Model\Authentication::LOCKOUT_THRESHOLD_PATH], [\Magento\Customer\Model\Authentication::MAX_FAILURES_PATH])->willReturnOnConsecutiveCalls(1, 1);
         $this->customerSecure->expects($this->once())->method('isCustomerLocked')->willReturn(false);
         $this->customerRegistryMock->expects($this->once())->method('retrieve')->with($customerId)->willReturn($this->customerSecure);
         $this->customerRepositoryMock->expects($this->once())->method('save')->willReturn($customerMock);
         $this->setExpectedException('\\Magento\\Framework\\Exception\\InvalidEmailOrPasswordException');
         $this->authentication->authenticate($customerId, $password);
     }
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:26,代码来源:AuthenticationTest.php


示例18: testAdminAuthenticateUpdateLockingInfo

 public function testAdminAuthenticateUpdateLockingInfo()
 {
     $password = "myP@sw0rd";
     $uid = 123;
     $authResult = false;
     $firstFailure = '1965-07-08 11:14:15.638276';
     $numOfFailures = 5;
     /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getPassword', 'getUser', 'getResult'])->getMock();
     /** @var ModelUser|\PHPUnit_Framework_MockObject_MockObject $userMock */
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getFailuresNum', 'getFirstFailure'])->getMock();
     $eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
     $eventMock->expects($this->once())->method('getPassword')->willReturn($password);
     $eventMock->expects($this->once())->method('getUser')->willReturn($userMock);
     $eventMock->expects($this->once())->method('getResult')->willReturn($authResult);
     $userMock->expects($this->once())->method('getId')->willReturn($uid);
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     $userMock->expects($this->once())->method('getFailuresNum')->willReturn($numOfFailures);
     $userMock->expects($this->once())->method('getFirstFailure')->willReturn($firstFailure);
     $this->userMock->expects($this->once())->method('updateFailure');
     $this->model->execute($eventObserverMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:24,代码来源:AuthObserverTest.php


示例19: getMaxFailures

 /**
  * Get admin maxiumum security failures from config
  *
  * @return int
  */
 public function getMaxFailures()
 {
     return (int) $this->backendConfig->getValue('admin/security/lockout_failures');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:ObserverConfig.php


示例20: authenticate

 /**
  * Authenticate user name and password and save loaded record
  *
  * @param string $username
  * @param string $password
  * @return bool
  * @throws \Magento\Framework\Model\Exception
  * @throws \Magento\Backend\Model\Auth\Exception
  * @throws \Magento\Backend\Model\Auth\Plugin\Exception
  */
 public function authenticate($username, $password)
 {
     $config = $this->_config->isSetFlag('admin/security/use_case_sensitive_login');
     $result = false;
     try {
         $this->_eventManager->dispatch('admin_user_authenticate_before', array('username' => $username, 'user' => $this));
         $this->loadByUsername($username);
         $sensitive = $config ? $username == $this->getUsername() : true;
         if ($sensitive && $this->getId() && $this->_encryptor->validateHash($password, $this->getPassword())) {
             if ($this->getIsActive() != '1') {
                 throw new \Magento\Backend\Model\Auth\Exception(__('This account is inactive.'));
             }
             if (!$this->hasAssigned2Role($this->getId())) {
                 throw new \Magento\Backend\Model\Auth\Exception(__('Access denied.'));
             }
             $result = true;
         }
         $this->_eventManager->dispatch('admin_user_authenticate_after', array('username' => $username, 'password' => $password, 'user' => $this, 'result' => $result));
     } catch (\Magento\Framework\Model\Exception $e) {
         $this->unsetData();
         throw $e;
     }
     if (!$result) {
         $this->unsetData();
     }
     return $result;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:37,代码来源:User.php



注:本文中的Magento\Backend\App\ConfigInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Action\Context类代码示例发布时间:2022-05-23
下一篇:
PHP App\Action类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap