Skip to content

Commit 8a77928

Browse files
ENGCOM-3680: [Backport] Fixed subscribe to newsletter if you already have an account issue #18912
- Merge Pull Request #18912 from ravi-chandra3197/magento2:patch-8952 - Merged commits: 1. b1fc4a7
2 parents be2badc + b1fc4a7 commit 8a77928

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)