В нашето приложение Magento използвахме транзакционен шаблон за имейл, за да изпратим имейл за нулиране на парола.
Когато щракнем върху бутона submit
в прозореца за забравена парола, ще бъде изпратен един имейл въз основа на имейл шаблона...
Следва кодът в Accountcontroller
$newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
/*$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->sendPasswordResetConfirmationEmail();*/
$templateId = "Reset_password_user";
$flname = $customer->getFirstname().' '.$customer->getLastname();
$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId);
$vars = array('name' => ucwords($flname), 'userid' => $customer->getId(), 'tocken' => $newResetPasswordLinkToken);
$emailTemplate->getProcessedTemplate($vars);
$storeId = Mage::app()->getStore()->getStoreId();
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', $storeId));
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', $storeId));
$emailTemplate->send($email,ucwords($flname), $vars);
Следното ще бъде съдържанието на имейла:
There was recently a request to change the password for your account.
If you requested this password change, please click on the following link to reset your password: http://mywebsite.com/index.php/customer/account/resetpassword/?id=3607&token=f74609505166ef132345ba78539e6b90
If clicking the link does not work, please copy and paste the URL into your browser instead.
If you did not make this request, you can ignore this message and your password will remain the same.
И така, какъв е проблемът тук?
Когато щракна върху връзката в имейла, тя ще зареди връзката за забравена парола със съобщение за грешка, което гласи:
Your password reset link has expired.