【问题标题】:magento 1.13 reset password not showing error messagesmagento 1.13 重置密码不显示错误信息
【发布时间】:2016-06-29 16:31:16
【问题描述】:

在 magento EE 1.13 中,重置忘记密码页面在应用补丁 6788 后未显示任何错误消息。这是我的 resetPasswordPostAction() 错误消息添加到会话并重定向到 changeForgotten 操作

if (!empty($errorMessages)) {
            $this->_getSession()
                ->setCustomerFormData($this->getRequest()->getPost());
            foreach ($errorMessages as $errorMessage) {
                $this->_getSession()->addError($errorMessage);
            }
            $this->_redirect('*/*/changeforgotten');
            return $this;
        }

并在 resetforgottenpassword.phtml 中显示错误消息,例如

<?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>

核心 changeForgottenAction 是:

public function changeForgottenAction()
    {
        try {
            list($customerId, $resetPasswordLinkToken) = $this->_getRestorePasswordParameters($this->_getSession());
            $this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken);
            $this->loadLayout();
            $this->renderLayout();

        } catch (Exception $exception) {
            $this->_getSession()->addError($this->_getHelper('customer')->__('Your password reset link has expired.'));
            $this->_redirect('*/*/forgotpassword');
        }
    }

【问题讨论】:

    标签: php magento


    【解决方案1】:

    在深入研究核心文件后发现 changeForgottenAction() 没有初始化布局消息。在$this-&gt;loadLayout(); 之后使用下面的代码

            $this->_initLayoutMessages('customer/session');
    

    最终的 changeForgottenAction() 动作是:

    public function changeForgottenAction()
        {
            try {
                list($customerId, $resetPasswordLinkToken) = $this->_getRestorePasswordParameters($this->_getSession());
                $this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken);
                $this->loadLayout();
                $this->_initLayoutMessages('customer/session');
                $this->renderLayout();
    
            } catch (Exception $exception) {
                $this->_getSession()->addError($this->_getHelper('customer')->__('Your password reset link has expired.'));
                $this->_redirect('*/*/forgotpassword');
            }
        }
    

    谢谢!!

    【讨论】:

      猜你喜欢
      • 2020-04-18
      • 2012-06-14
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      相关资源
      最近更新 更多