当前位置: 首页>>代码示例>>PHP>>正文


PHP EncryptorInterface::validateHash方法代码示例

本文整理汇总了PHP中Magento\Framework\Encryption\EncryptorInterface::validateHash方法的典型用法代码示例。如果您正苦于以下问题:PHP EncryptorInterface::validateHash方法的具体用法?PHP EncryptorInterface::validateHash怎么用?PHP EncryptorInterface::validateHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Encryption\EncryptorInterface的用法示例。


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

示例1: authenticate

 /**
  * {@inheritdoc}
  */
 public function authenticate($username, $password)
 {
     try {
         switch ($this->advancedLoginConfigProvider->getLoginMode()) {
             case LoginMode::LOGIN_TYPE_ONLY_ATTRIBUTE:
                 $customer = $this->loginViaCustomerAttributeOnly($username);
                 break;
             case LoginMode::LOGIN_TYPE_BOTH:
                 $customer = $this->loginViaCustomerAttributeOrEmail($username);
                 break;
             default:
                 $customer = $this->loginViaEmailOnly($username);
                 break;
         }
     } catch (NoSuchEntityException $e) {
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     $this->checkPasswordStrength($password);
     $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
     if (!$this->encryptor->validateHash($password, $hash)) {
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     if ($customer->getConfirmation() && $this->isConfirmationRequired($customer)) {
         throw new EmailNotConfirmedException(__('This account is not confirmed.'));
     }
     $customerModel = $this->customerFactory->create()->updateData($customer);
     $this->eventManager->dispatch('customer_customer_authenticated', ['model' => $customerModel, 'password' => $password]);
     $this->eventManager->dispatch('customer_data_object_login', ['customer' => $customer]);
     return $customer;
 }
开发者ID:semaio,项目名称:magento2-advancedlogin,代码行数:33,代码来源:AccountManagement.php

示例2: validatePasswordAndLockStatus

 /**
  * Validate that password is correct and customer is not locked
  *
  * @param \Magento\Customer\Api\Data\CustomerInterface $customer
  * @param string $password
  * @return $this
  * @throws InvalidEmailOrPasswordException
  */
 public function validatePasswordAndLockStatus(\Magento\Customer\Api\Data\CustomerInterface $customer, $password)
 {
     $customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
     $hash = $customerSecure->getPasswordHash();
     if (!$this->encryptor->validateHash($password, $hash)) {
         $this->_eventManager->dispatch('customer_password_invalid', ['username' => $customer->getEmail(), 'password' => $password]);
         $this->checkIfLocked($customer);
         throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
     }
     return $this;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:19,代码来源:AccountManagement.php

示例3: authenticate

 /**
  * {@inheritdoc}
  */
 public function authenticate($customerId, $password)
 {
     $customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
     $hash = $customerSecure->getPasswordHash();
     if (!$this->encryptor->validateHash($password, $hash)) {
         $this->processAuthenticationFailure($customerId);
         if ($this->isLocked($customerId)) {
             throw new UserLockedException(__('The account is locked.'));
         }
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     return true;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:16,代码来源:Authentication.php

示例4: verifyIdentity

 /**
  * Ensure that provided password matches the current user password. Check if the current user account is active.
  *
  * @param string $password
  * @return bool
  * @throws \Magento\Framework\Exception\AuthenticationException
  */
 public function verifyIdentity($password)
 {
     $result = false;
     if ($this->_encryptor->validateHash($password, $this->getPassword())) {
         if ($this->getIsActive() != '1') {
             throw new AuthenticationException(__('This account is inactive.'));
         }
         if (!$this->hasAssigned2Role($this->getId())) {
             throw new AuthenticationException(__('You need more permissions to access this.'));
         }
         $result = true;
     }
     return $result;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:21,代码来源:User.php

示例5: changePasswordForCustomer

 /**
  * Change customer password.
  *
  * @param CustomerModel $customer
  * @param string $currentPassword
  * @param string $newPassword
  * @return bool true on success
  * @throws InputException
  * @throws InvalidEmailOrPasswordException
  */
 private function changePasswordForCustomer($customer, $currentPassword, $newPassword)
 {
     $customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
     $hash = $customerSecure->getPasswordHash();
     if (!$this->encryptor->validateHash($currentPassword, $hash)) {
         throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
     }
     $customerSecure->setRpToken(null);
     $customerSecure->setRpTokenCreatedAt(null);
     $this->checkPasswordStrength($newPassword);
     $customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
     $this->customerRepository->save($customer);
     // FIXME: Are we using the proper template here?
     try {
         $this->sendPasswordResetNotificationEmail($customer);
     } catch (MailException $e) {
         $this->logger->critical($e);
     }
     return true;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:AccountManagement.php

示例6: validateUserPassword

 /**
  * Validate user password
  *
  * @param string $password
  * @return bool
  */
 public function validateUserPassword($password)
 {
     $userPasswordHash = $this->_backendAuthSession->getUser()->getPassword();
     return $this->_encryptor->validateHash($password, $userPasswordHash);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:Backup.php

示例7: 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

示例8: validatePassword

 /**
  * Validate password with salted hash
  *
  * @param string $password
  * @return boolean
  */
 public function validatePassword($password)
 {
     $hash = $this->getPasswordHash();
     if (!$hash) {
         return false;
     }
     return $this->_encryptor->validateHash($password, $hash);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Customer.php


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