Skip to content

Commit bd36872

Browse files
authored
ENGCOM-3431: Fixed subscribe to newsletter if you already have an account issue #8952 -2.3 develop #19164
2 parents 811ed3a + 284bd75 commit bd36872

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ public function __construct(
8080
protected function validateEmailAvailable($email)
8181
{
8282
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
83-
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
84-
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)
83+
if ($this->_customerSession->isLoggedIn()
84+
&& ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
85+
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId))
8586
) {
8687
throw new LocalizedException(
8788
__('This email address is already assigned to another user.')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testNewActionUsedEmail()
5757
$this->dispatch('newsletter/subscriber/new');
5858

5959
$this->assertSessionMessages($this->equalTo([
60-
'This email address is already assigned to another user.',
60+
'Thank you for your subscription.',
6161
]));
6262
$this->assertRedirect($this->anything());
6363
}

0 commit comments

Comments
 (0)