Skip to content

Commit 1f8cbd9

Browse files
author
Oleksii Korshenko
authored
ENGCOM-3680: [Backport] Fixed subscribe to newsletter if you already have an account issue #18912
2 parents e73a7a4 + 8a77928 commit 1f8cbd9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public function __construct(
7777
protected function validateEmailAvailable($email)
7878
{
7979
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
80-
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
80+
if ($this->_customerSession->isLoggedIn()
81+
&& ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
8182
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)
82-
) {
83+
)) {
8384
throw new LocalizedException(
8485
__('This email address is already assigned to another user.')
8586
);

dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ public function testNewActionUsedEmail()
5353
$this->getRequest()->setPostValue([
5454
'email' => 'customer@example.com',
5555
]);
56-
5756
$this->dispatch('newsletter/subscriber/new');
5857

5958
$this->assertSessionMessages($this->equalTo([
60-
'There was a problem with the subscription: This email address is already assigned to another user.',
59+
'Thank you for your subscription.',
6160
]));
6261
$this->assertRedirect($this->anything());
6362
}

0 commit comments

Comments
 (0)