Skip to content

Commit

Permalink
MAGETWO-38049: Wrong Reset Password link in a Welcome email when cust…
Browse files Browse the repository at this point in the history
…omer was created on backend
  • Loading branch information
Alexander Paliarush authored and vpaladiychuk committed Jul 15, 2015
1 parent 6a2842b commit e12cf68
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 30 deletions.
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject Welcome to {{var store.getFrontendName()}} @-->
<!--@vars {
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->
Expand All @@ -19,7 +19,7 @@
{{trans
'To sign in to our site, use these credentials during checkout or on the <a href="%customer_url">My Account</a> page:'

customer_url=$store.getUrl('customer/account/')
customer_url=$this.getUrl($store, 'customer/account/')
|raw}}
</p>
<ul>
Expand All @@ -30,7 +30,7 @@
{{trans
'Forgot your account password? Click <a href="%reset_url">here</a> to reset it.'

reset_url="$store.getUrl('customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])"
reset_url="$this.getUrl($store, 'customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])"
|raw}}
</p>
<p>{{trans "When you sign in to your account, you will be able to:"}}</p>
Expand Down
Expand Up @@ -6,8 +6,8 @@
-->
<!--@subject Please confirm your {{var store.getFrontendName()}} account @-->
<!--@vars {
"var store.getUrl('customer/account/confirm/', [_query:[id:$customer.id, key:$customer.confirmation, back_url:$back_url]])":"Account Confirmation URL",
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/confirm/', [_query:[id:$customer.id, key:$customer.confirmation, back_url:$back_url]])":"Account Confirmation URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->
Expand All @@ -23,7 +23,7 @@
<table class="inner-wrapper" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<a href="{{var store.getUrl('customer/account/confirm/', [_query:[id:$customer.id, key:$customer.confirmation, back_url:$back_url]])}}" target="_blank">{{trans "Confirm Your Account"}}</a>
<a href="{{var this.getUrl($store, 'customer/account/confirm/', [_query:[id:$customer.id, key:$customer.confirmation, back_url:$back_url]])}}" target="_blank">{{trans "Confirm Your Account"}}</a>
</td>
</tr>
</table>
Expand Down
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject Welcome to {{var store.getFrontendName()}} @-->
<!--@vars {
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->
Expand All @@ -18,7 +18,7 @@
{{trans
'To sign in to our site, use these credentials during checkout or on the <a href="%customer_url">My Account</a> page:'

customer_url=$store.getUrl('customer/account/')
customer_url=$this.getUrl($store, 'customer/account/')
|raw}}
</p>
<ul>
Expand All @@ -29,7 +29,7 @@
{{trans
'Forgot your account password? Click <a href="%reset_url">here</a> to reset it.'

reset_url="$store.getUrl('customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])"
reset_url="$this.getUrl($store, 'customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])"
|raw}}
</p>
<p>{{trans "When you sign in to your account, you will be able to:"}}</p>
Expand Down
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject Reset your {{var store.getFrontendName()}} password @-->
<!--@vars {
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl(store, 'customer/account/')":"Customer Account URL",
"var customer.name":"Customer Name"
} @-->
{{template config_path="design/email/header_template"}}
Expand All @@ -21,7 +21,7 @@
<table class="inner-wrapper" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<a href="{{var store.getUrl('customer/account/createPassword', [_query:[id:$customer.id, token:$customer.rp_token]])}}" target="_blank">{{trans "Reset Password"}}</a>
<a href="{{var this.getUrl($store, 'customer/account/createPassword', [_query:[id:$customer.id, token:$customer.rp_token]])}}" target="_blank">{{trans "Reset Password"}}</a>
</td>
</tr>
</table>
Expand Down
Expand Up @@ -7,7 +7,7 @@
<!--@subject Reset your {{var store.getFrontendName()}} password @-->
<!--@vars {
"var customer.name":"Customer Name",
"var store.getUrl('customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])":"Reset Password URL"
"var this.getUrl($store, 'customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])":"Reset Password URL"
} @-->
{{template config_path="design/email/header_template"}}

Expand All @@ -21,7 +21,7 @@
<table class="inner-wrapper" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<a href="{{var store.getUrl('customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])}}" target="_blank">{{trans "Reset Password"}}</a>
<a href="{{var this.getUrl($store, 'customer/account/createPassword/', [_query:[id:$customer.id, token:$customer.rp_token]])}}" target="_blank">{{trans "Reset Password"}}</a>
</td>
</tr>
</table>
Expand Down
25 changes: 25 additions & 0 deletions app/code/Magento/Email/Model/AbstractTemplate.php
Expand Up @@ -146,6 +146,11 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
*/
protected $emailConfig;

/**
* @var \Magento\Framework\UrlInterface
*/
private $urlModel;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\View\DesignInterface $design
Expand All @@ -157,6 +162,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param Template\Config $emailConfig
* @param \Magento\Email\Model\TemplateFactory $templateFactory
* @param \Magento\Framework\Url $urlModel
* @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
Expand All @@ -172,6 +178,7 @@ public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
Template\Config $emailConfig,
TemplateFactory $templateFactory,
\Magento\Framework\UrlInterface $urlModel,
array $data = []
) {
$this->design = $design;
Expand All @@ -184,6 +191,7 @@ public function __construct(
$this->scopeConfig = $scopeConfig;
$this->emailConfig = $emailConfig;
$this->templateFactory = $templateFactory;
$this->urlModel = $urlModel;
parent::__construct($context, $registry, null, null, $data);
}

Expand Down Expand Up @@ -716,4 +724,21 @@ abstract protected function getFilterFactory();
* @return int|string
*/
abstract public function getType();

/**
* Generate URL for the specified store.
*
* @param \Magento\Store\Model\Store $store
* @param string $route
* @param array $params
* @return string
*/
public function getUrl(\Magento\Store\Model\Store $store, $route = '', $params = [])
{
$url = $this->urlModel->setScope($store);
if ($this->storeManager->getStore()->getId() != $store->getId()) {
$params['_scope_to_url'] = true;
}
return $url->getUrl($route, $params);
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/Email/Model/BackendTemplate.php
Expand Up @@ -30,6 +30,7 @@ class BackendTemplate extends Template
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Email\Model\Template\Config $emailConfig
* @param \Magento\Email\Model\TemplateFactory $templateFactory
* @param \Magento\Framework\UrlInterface $urlModel
* @param \Magento\Email\Model\Template\FilterFactory $filterFactory
* @param \Magento\Config\Model\Config\Structure $structure
* @param array $data
Expand All @@ -47,6 +48,7 @@ public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Email\Model\Template\Config $emailConfig,
\Magento\Email\Model\TemplateFactory $templateFactory,
\Magento\Framework\UrlInterface $urlModel,
\Magento\Email\Model\Template\FilterFactory $filterFactory,
\Magento\Config\Model\Config\Structure $structure,
array $data = []
Expand All @@ -63,6 +65,7 @@ public function __construct(
$scopeConfig,
$emailConfig,
$templateFactory,
$urlModel,
$filterFactory,
$data
);
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/Email/Model/Template.php
Expand Up @@ -98,15 +98,15 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ
protected $_sendingException = null;

/**
* Constructor
*
* Email filter factory
*
* @var \Magento\Email\Model\Template\FilterFactory
*/
private $filterFactory;

/**
* Initialize dependencies
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\View\DesignInterface $design
* @param \Magento\Framework\Registry $registry
Expand All @@ -117,6 +117,7 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param Template\Config $emailConfig
* @param \Magento\Email\Model\TemplateFactory $templateFactory
* @param \Magento\Framework\UrlInterface $urlModel
* @param \Magento\Email\Model\Template\FilterFactory $filterFactory
* @param array $data
*
Expand All @@ -133,6 +134,7 @@ public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Email\Model\Template\Config $emailConfig,
\Magento\Email\Model\TemplateFactory $templateFactory,
\Magento\Framework\UrlInterface $urlModel,
\Magento\Email\Model\Template\FilterFactory $filterFactory,
array $data = []
) {
Expand All @@ -148,6 +150,7 @@ public function __construct(
$scopeConfig,
$emailConfig,
$templateFactory,
$urlModel,
$data
);
}
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Email/etc/di.xml
Expand Up @@ -11,4 +11,14 @@
<preference for="Magento\Framework\Mail\TransportInterface" type="Magento\Framework\Mail\Transport" />
<preference for="Magento\Framework\Mail\MessageInterface" type="Magento\Framework\Mail\Message" />
<preference for="Magento\Framework\Mail\Template\SenderResolverInterface" type="Magento\Email\Model\Template\SenderResolver" />
<type name="Magento\Email\Model\BackendTemplate">
<arguments>
<argument name="urlModel" xsi:type="object" shared="false">Magento\Backend\Model\Url</argument>
</arguments>
</type>
<type name="Magento\Email\Model\Template">
<arguments>
<argument name="urlModel" xsi:type="object" shared="false">Magento\Framework\Url</argument>
</arguments>
</type>
</config>
3 changes: 3 additions & 0 deletions app/code/Magento/Newsletter/Model/Template.php
Expand Up @@ -76,6 +76,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate
* @param \Magento\Email\Model\Template\Config $emailConfig
* @param \Magento\Email\Model\TemplateFactory $templateFactory The template directive requires an email
* template model, not newsletter model, as templates overridden in backend are loaded from email table.
* @param \Magento\Framework\Url $urlModel
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Newsletter\Model\Template\FilterFactory $filterFactory,
* @param array $data
Expand All @@ -92,6 +93,7 @@ public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Email\Model\Template\Config $emailConfig,
\Magento\Email\Model\TemplateFactory $templateFactory,
\Magento\Framework\UrlInterface $urlModel,
\Magento\Framework\App\RequestInterface $request,
\Magento\Newsletter\Model\Template\FilterFactory $filterFactory,
array $data = []
Expand All @@ -107,6 +109,7 @@ public function __construct(
$scopeConfig,
$emailConfig,
$templateFactory,
$urlModel,
$data
);
$this->_storeManager = $storeManager;
Expand Down
Expand Up @@ -10,7 +10,7 @@
"var comment":"Credit Memo Comment",
"var creditmemo.increment_id":"Credit Memo Id",
"layout handle=\"sales_email_order_creditmemo_items\" creditmemo=$creditmemo order=$order":"Credit Memo Items Grid",
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var order.getCustomerName()":"Customer Name",
"var order.increment_id":"Order Id",
"var payment_html|raw":"Payment Details",
Expand All @@ -26,7 +26,7 @@
<p class="greeting">{{trans "%name," name=$order.getCustomerName()}}</p>
<p>
{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$store.getUrl('customer/account/') |raw}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store, 'customer/account/') |raw}}
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{depend store_hours}}
{{trans 'Our hours are <span class="no-link">%store_hours</span>.' store_hours=$store_hours |raw}}
Expand Down
Expand Up @@ -8,7 +8,7 @@
<!--@vars {
"var comment":"Credit Memo Comment",
"var creditmemo.increment_id":"Credit Memo Id",
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var order.getCustomerName()":"Customer Name",
"var order.increment_id":"Order Id",
"var order.getStatusLabel()":"Order Status"
Expand All @@ -27,7 +27,7 @@
order_status=$order.getStatusLabel()
|raw}}
</p>
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$store.getUrl('customer/account/') |raw}}</p>
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store, 'customer/account/') |raw}}</p>
<p>
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{depend store_hours}}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Sales/view/frontend/email/invoice_new.html
Expand Up @@ -7,7 +7,7 @@
<!--@subject {{var store.getFrontendName()}}: Invoice # {{var invoice.increment_id}} for Order # {{var order.increment_id}} @-->
<!--@vars {
"var formattedBillingAddress|raw":"Billing Address",
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var order.getCustomerName()":"Customer Name",
"var comment":"Invoice Comment",
"var invoice.increment_id":"Invoice Id",
Expand All @@ -26,7 +26,7 @@
<p class="greeting">{{trans "%name," name=$order.getCustomerName()}}</p>
<p>
{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$store.getUrl('customer/account/') |raw}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store, 'customer/account/') |raw}}
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{depend store_hours}}
{{trans 'Our hours are <span class="no-link">%store_hours</span>.' store_hours=$store_hours |raw}}
Expand Down
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject {{var store.getFrontendName()}}: Invoice # {{var invoice.increment_id}} update @-->
<!--@vars {
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var order.getCustomerName()":"Customer Name",
"var comment":"Invoice Comment",
"var invoice.increment_id":"Invoice Id",
Expand All @@ -27,7 +27,7 @@
order_status=$order.getStatusLabel()
|raw}}
</p>
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$store.getUrl('customer/account/') |raw}}</p>
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store, 'customer/account/') |raw}}</p>
<p>
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{depend store_hours}}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/view/frontend/email/order_new.html
Expand Up @@ -24,7 +24,7 @@
<p>
{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}
{{trans "Once your package ships we will send you a tracking number."}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$store.getUrl('customer/account/') |raw}}
{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store, 'customer/account/') |raw}}
</p>
<p>
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Sales/view/frontend/email/order_update.html
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject {{var store.getFrontendName()}}: Order # {{var order.increment_id}} update @-->
<!--@vars {
"var store.getUrl('customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var order.getCustomerName()":"Customer Name",
"var comment":"Order Comment",
"var order.increment_id":"Order Id",
Expand All @@ -26,7 +26,7 @@
order_status=$order.getStatusLabel()
|raw}}
</p>
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$store.getUrl('customer/account/') |raw}}</p>
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store, 'customer/account/') |raw}}</p>
<p>
{{trans 'If you have questions about your order, you can email us at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{depend store_hours}}
Expand Down

0 comments on commit e12cf68

Please sign in to comment.