Skip to content

MC-33148: A link to resend a confirmation email is not clickable #27662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/code/Magento/Catalog/Helper/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function productAttribute($product, $attributeHtml, $attributeName)
if ($attributeHtml !== null
&& $attribute->getIsHtmlAllowedOnFront()
&& $attribute->getIsWysiwygEnabled()
&& $this->isDirectivesExists($attributeHtml)
&& $this->isDirectivesExists((string)$attributeHtml)
) {
$attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml);
}
Expand Down Expand Up @@ -219,7 +219,7 @@ public function categoryAttribute($category, $attributeHtml, $attributeName)
if ($attributeHtml !== null
&& $attribute->getIsHtmlAllowedOnFront()
&& $attribute->getIsWysiwygEnabled()
&& $this->isDirectivesExists($attributeHtml)
&& $this->isDirectivesExists((string)$attributeHtml)

) {
$attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml);
Expand All @@ -238,7 +238,7 @@ public function categoryAttribute($category, $attributeHtml, $attributeName)
* @param string $attributeHtml
* @return bool
*/
public function isDirectivesExists($attributeHtml)
public function isDirectivesExists(string $attributeHtml): bool
{
$matches = false;
foreach ($this->directivePatterns as $pattern) {
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Customer/Controller/Account/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/**
* Class Confirm
*
* Confirm class is responsible for account confirmation flow
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Confirm extends AbstractAccount implements HttpGetActionInterface
Expand Down Expand Up @@ -168,7 +170,7 @@ public function execute()
$metadata->setPath('/');
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}
$this->messageManager->addSuccessMessage($this->getSuccessMessage());
$this->messageManager->addSuccess($this->getSuccessMessage());
$resultRedirect->setUrl($this->getSuccessRedirect());
return $resultRedirect;
} catch (StateException $e) {
Expand Down
13 changes: 9 additions & 4 deletions app/code/Magento/Customer/Controller/Account/LoginPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class LoginPost extends AbstractAccount implements CsrfAwareActionInterface, Htt
*/
private $cookieMetadataManager;

/**
* @var CustomerUrl
*/
private $customerUrl;

/**
* @param Context $context
* @param Session $customerSession
Expand Down Expand Up @@ -199,11 +204,11 @@ public function execute()
return $resultRedirect;
}
} catch (EmailNotConfirmedException $e) {
$value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
$message = __(
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
$value
$this->messageManager->addComplexErrorMessage(
'confirmAccountErrorMessage',
['url' => $this->customerUrl->getEmailConfirmationUrl($login['username'])]
);
$this->session->setUsername($login['username']);
} catch (AuthenticationException $e) {
$message = __(
'The account sign-in was incorrect or your account is disabled temporarily. '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,77 +23,77 @@ class ConfirmTest extends \PHPUnit\Framework\TestCase
protected $model;

/**
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\App\RequestInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $requestMock;

/**
* @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\App\ResponseInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $responseMock;

/**
* @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Customer\Model\Session|\PHPUnit\Framework\MockObject\MockObject
*/
protected $customerSessionMock;

/**
* @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $redirectMock;

/**
* @var \Magento\Framework\Url|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Url|\PHPUnit\Framework\MockObject\MockObject
*/
protected $urlMock;

/**
* @var \Magento\Customer\Api\AccountManagementInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Customer\Api\AccountManagementInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $customerAccountManagementMock;

/**
* @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $customerRepositoryMock;

/**
* @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $customerDataMock;

/**
* @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Message\ManagerInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $messageManagerMock;

/**
* @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Customer\Helper\Address|\PHPUnit\Framework\MockObject\MockObject
*/
protected $addressHelperMock;

/**
* @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Store\Model\StoreManager|\PHPUnit\Framework\MockObject\MockObject
*/
protected $storeManagerMock;

/**
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Store\Model\Store|\PHPUnit\Framework\MockObject\MockObject
*/
protected $storeMock;

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $scopeConfigMock;

/**
* @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\App\Action\Context|\PHPUnit\Framework\MockObject\MockObject
*/
protected $contextMock;

/**
* @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit\Framework\MockObject\MockObject
*/
protected $redirectResultMock;

Expand Down Expand Up @@ -282,7 +282,7 @@ public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $ad
->willReturnSelf();

$this->messageManagerMock->expects($this->any())
->method('addSuccessMessage')
->method('addSuccess')
->with($this->stringContains($successMessage))
->willReturnSelf();

Expand Down Expand Up @@ -402,7 +402,7 @@ public function testSuccessRedirect(
->willReturnSelf();

$this->messageManagerMock->expects($this->any())
->method('addSuccessMessage')
->method('addSuccess')
->with($this->stringContains($successMessage))
->willReturnSelf();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,62 +28,62 @@ class LoginPostTest extends \PHPUnit\Framework\TestCase
protected $controller;

/**
* @var Context | \PHPUnit_Framework_MockObject_MockObject
* @var Context | \PHPUnit\Framework\MockObject\MockObject
*/
protected $context;

/**
* @var Session | \PHPUnit_Framework_MockObject_MockObject
* @var Session | \PHPUnit\Framework\MockObject\MockObject
*/
protected $session;

/**
* @var AccountManagementInterface | \PHPUnit_Framework_MockObject_MockObject
* @var AccountManagementInterface | \PHPUnit\Framework\MockObject\MockObject
*/
protected $accountManagement;

/**
* @var Url | \PHPUnit_Framework_MockObject_MockObject
* @var Url | \PHPUnit\Framework\MockObject\MockObject
*/
protected $url;

/**
* @var \Magento\Framework\Data\Form\FormKey\Validator | \PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Data\Form\FormKey\Validator | \PHPUnit\Framework\MockObject\MockObject
*/
protected $formkeyValidator;

/**
* @var AccountRedirect | \PHPUnit_Framework_MockObject_MockObject
* @var AccountRedirect | \PHPUnit\Framework\MockObject\MockObject
*/
protected $accountRedirect;

/**
* @var Http | \PHPUnit_Framework_MockObject_MockObject
* @var Http | \PHPUnit\Framework\MockObject\MockObject
*/
protected $request;

/**
* @var Redirect | \PHPUnit_Framework_MockObject_MockObject
* @var Redirect | \PHPUnit\Framework\MockObject\MockObject
*/
protected $resultRedirect;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $redirectFactory;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $redirect;

/**
* @var \Magento\Framework\Message\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Message\ManagerInterface | \PHPUnit\Framework\MockObject\MockObject
*/
protected $messageManager;

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit\Framework\MockObject\MockObject
*/
protected $scopeConfig;

Expand Down Expand Up @@ -551,14 +551,12 @@ protected function mockExceptions($exception, $username)
->with($username)
->willReturn($url);

$message = __(
'This account is not confirmed.' .
' <a href="%1">Click here</a> to resend confirmation email.',
$url
);
$this->messageManager->expects($this->once())
->method('addErrorMessage')
->with($message)
->method('addComplexErrorMessage')
->with(
'confirmAccountErrorMessage',
['url' => $url]
)
->willReturnSelf();

$this->session->expects($this->once())
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Customer/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
<item name="template" xsi:type="string">Magento_Customer::messages/confirmAccountSuccessMessage.phtml</item>
</item>
</item>
<item name="confirmAccountErrorMessage" xsi:type="array">
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
<item name="data" xsi:type="array">
<item name="template" xsi:type="string">Magento_Customer::messages/confirmAccountErrorMessage.phtml</item>
</item>
</item>
<item name="customerVatShippingAddressSuccessMessage" xsi:type="array">
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
<item name="data" xsi:type="array">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/** @var \Magento\Framework\View\Element\Template $block */
/** @var \Magento\Framework\Escaper $escaper */

?>
<?= $escaper->escapeHtml(
__(
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
$block->getData('url')
),
['a']
);
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function _testAttribute($method, $entityCode, $expectedResult)
try {
$this->assertEquals(
$expectedResult,
$this->_helper->{$method}(uniqid(), "<p>line1</p>\nline2", $attributeName)
$this->_helper->{$method}(uniqid(), __("<p>line1</p>\nline2"), $attributeName)
);

$attribute->setIsHtmlAllowedOnFront($isHtml)->setIsWysiwygEnabled($isWysiwyg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class LoginPostTest extends AbstractController
/** @var EncoderInterface */
private $urlEncoder;

/**
* @var Url
*/
private $customerUrl;

/**
* @inheritdoc
*/
Expand All @@ -37,6 +42,7 @@ protected function setUp()

$this->session = $this->_objectManager->get(Session::class);
$this->urlEncoder = $this->_objectManager->get(EncoderInterface::class);
$this->customerUrl = $this->_objectManager->get(Url::class);
}

/**
Expand Down Expand Up @@ -107,13 +113,16 @@ public function missingParametersDataProvider(): array
*/
public function testLoginWithUnconfirmedPassword(): void
{
$this->markTestSkipped('Blocked by MC-31370.');
$email = '[email protected]';
$this->prepareRequest($email, 'Qwert12345');
$this->dispatch('customer/account/loginPost');
$this->assertEquals($email, $this->session->getUsername());
$message = __(
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
$this->customerUrl->getEmailConfirmationUrl($this->session->getUsername())
);
$this->assertSessionMessages(
$this->equalTo([(string)__('This account is not confirmed. Click here to resend confirmation email.')]),
$this->equalTo([(string)$message]),
MessageInterface::TYPE_ERROR
);
}
Expand Down