Skip to content

Commit

Permalink
Fixed subscribe to newsletter if you already have an account issue ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-chandra3197 committed Nov 12, 2018
1 parent 78b694f commit ebfffe4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public function __construct(
protected function validateEmailAvailable($email)
{
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)
if ($this->_customerSession->isLoggedIn()
&& ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId))
) {
throw new LocalizedException(
__('This email address is already assigned to another user.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testNewActionUsedEmail()
$this->dispatch('newsletter/subscriber/new');

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

0 comments on commit ebfffe4

Please sign in to comment.