當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EncryptorInterface::validateHashVersion方法代碼示例

本文整理匯總了PHP中Magento\Framework\Encryption\EncryptorInterface::validateHashVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP EncryptorInterface::validateHashVersion方法的具體用法?PHP EncryptorInterface::validateHashVersion怎麽用?PHP EncryptorInterface::validateHashVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Encryption\EncryptorInterface的用法示例。


在下文中一共展示了EncryptorInterface::validateHashVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Upgrade customer password hash when customer has logged in
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $password = $observer->getEvent()->getData('password');
     /** @var \Magento\Customer\Model\Customer $model */
     $model = $observer->getEvent()->getData('model');
     $customer = $this->customerRepository->getById($model->getId());
     $customerSecure = $this->customerRegistry->retrieveSecureData($model->getId());
     if (!$this->encryptor->validateHashVersion($customerSecure->getPasswordHash(), true)) {
         $customerSecure->setPasswordHash($this->encryptor->getHash($password, true));
         $this->customerRepository->save($customer);
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:UpgradeCustomerPasswordObserver.php

示例2: execute

 /**
  * Admin locking and password hashing upgrade logic implementation
  *
  * @param EventObserver $observer
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function execute(EventObserver $observer)
 {
     $password = $observer->getEvent()->getPassword();
     /** @var User $user */
     $user = $observer->getEvent()->getUser();
     $authResult = $observer->getEvent()->getResult();
     if (!$authResult && $user->getId()) {
         // update locking information regardless whether user locked or not
         $this->_updateLockingInformation($user);
     }
     // check whether user is locked
     $lockExpires = $user->getLockExpires();
     if ($lockExpires) {
         $lockExpires = new \DateTime($lockExpires);
         if ($lockExpires > new \DateTime()) {
             throw new UserLockedException(__('You did not sign in correctly or your account is temporarily disabled.'));
         }
     }
     if (!$authResult) {
         return;
     }
     $this->userResource->unlock($user->getId());
     $latestPassword = $this->userResource->getLatestPassword($user->getId());
     $this->_checkExpiredPassword($latestPassword);
     if (!$this->encryptor->validateHashVersion($user->getPassword(), true)) {
         $user->setPassword($password)->setData('force_new_password', true)->save();
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:35,代碼來源:AuthObserver.php


注:本文中的Magento\Framework\Encryption\EncryptorInterface::validateHashVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。