我们如何直接在Magento2中看到创建密码页面?

How can we see the create password page in Magento2 directly?

如何在我的本地环境中访问“创建密码”页面?我的本地没有设置电子邮件功能,所以我无法通过浏览器访问该页面。

您可以进入页面: /vendor/magento/module-customer/Controller/Account/CreatePassword.php

更改 execute() 函数如下:

public function execute()
    {
        $resetPasswordToken = (string)$this->getRequest()->getParam('token');
        $customerId = (int)$this->getRequest()->getParam('id');

        $resultPage = $this->resultPageFactory->create();
                  $resultPage->getLayout()->getBlock('resetPassword')->setCustomerId($customerId)
                    ->setResetPasswordLinkToken($resetPasswordToken);
                return $resultPage;


    }

现在通过添加现有客户 ID 直接在浏览器中访问该页面,如下所示:

<website_name>/customer/account/createPassword/?id=<customer_id>&token=8ebf7486db44b57de5cafc308c6802b4