Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TrackAdminNewPasswordObserver.php
Go to the documentation of this file.
1 <?php
8 
12 
17 {
23  protected $observerConfig;
24 
30  protected $userResource;
31 
37  protected $authSession;
38 
44  protected $messageManager;
45 
52  public function __construct(
53  \Magento\User\Model\Backend\Config\ObserverConfig $observerConfig,
55  \Magento\Backend\Model\Auth\Session $authSession,
56  \Magento\Framework\Message\ManagerInterface $messageManager
57  ) {
58  $this->observerConfig = $observerConfig;
59  $this->userResource = $userResource;
60  $this->authSession = $authSession;
61  $this->messageManager = $messageManager;
62  }
63 
70  public function execute(EventObserver $observer)
71  {
72  /* @var $user \Magento\User\Model\User */
73  $user = $observer->getEvent()->getObject();
74  if ($user->getId()) {
75  $passwordHash = $user->getPassword();
76  if ($passwordHash && !$user->getForceNewPassword()) {
77  $this->userResource->trackPassword($user, $passwordHash);
78  $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED);
79  $this->authSession->unsPciAdminUserIsPasswordExpired();
80  }
81  }
82  }
83 }
__construct(\Magento\User\Model\Backend\Config\ObserverConfig $observerConfig, \Magento\User\Model\ResourceModel\User $userResource, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\Message\ManagerInterface $messageManager)
$user
Definition: dummy_user.php:13
const MESSAGE_ID_PASSWORD_EXPIRED
Definition: User.php:61