Skip to content

Commit ebfffe4

Browse files
Fixed subscribe to newsletter if you already have an account issue #8952
1 parent 78b694f commit ebfffe4

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
@@ -77,8 +77,9 @@ public function __construct(
7777
protected function validateEmailAvailable($email)
7878
{
7979
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
80-
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
81-
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)
80+
if ($this->_customerSession->isLoggedIn()
81+
&& ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
82+
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId))
8283
) {
8384
throw new LocalizedException(
8485
__('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-
'There was a problem with the subscription: 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)