/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $adminUserName = $input->getArgument(self::ARGUMENT_ADMIN_USERNAME);
     $userData = $this->adminUser->loadByUsername($adminUserName);
     $outputMessage = sprintf('Couldn\'t find the user account "%s"', $adminUserName);
     if ($userData) {
         if (isset($userData[self::USER_ID]) && $this->adminUser->unlock($userData[self::USER_ID])) {
             $outputMessage = sprintf('The user account "%s" has been unlocked', $adminUserName);
         } else {
             $outputMessage = sprintf('The user account "%s" was not locked or could not be unlocked', $adminUserName);
         }
     }
     $output->writeln('<info>' . $outputMessage . '</info>');
 }
Esempio n. 2
0
 /**
  * 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();
     }
 }
Esempio n. 3
0
 public function testUnlockWithInteger()
 {
     $inputData = 123;
     $returnData = 5;
     $this->resourceMock->expects($this->atLeastOnce())->method('getConnection')->willReturn($this->dbAdapterMock);
     $this->dbAdapterMock->expects($this->once())->method('update')->willReturn($returnData);
     $this->assertEquals($returnData, $this->model->unlock($inputData));
 }