Skip to content

Commit

Permalink
Single call for getMessages()
Browse files Browse the repository at this point in the history
app/code/Magento/User/Test/Unit/Observer/Backend/AuthObserverTest.php is checking for a single getMessages() call
  • Loading branch information
phoenix128 committed Apr 29, 2018
1 parent 0abb682 commit 8d8706e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/code/Magento/User/Observer/Backend/AuthObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ private function _checkExpiredPassword($latestPassword)
$message = __('It\'s time to <a href="%1">change your password</a>.', $myAccountUrl);
}

// Avoid duplicating the message
$this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED);
$messages = $this->messageManager->getMessages();

// Remove existing messages with same ID to avoid duplication
$messages->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED);

$this->messageManager->addNoticeMessage($message);
$message = $this->messageManager->getMessages()->getLastAddedMessage();
$message = $messages->getLastAddedMessage();
if ($message) {
$message->setIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED)->setIsSticky(true);
$this->authSession->setPciAdminUserIsPasswordExpired(true);
Expand Down

0 comments on commit 8d8706e

Please sign in to comment.