0

How to get Reset password link in the custom email template? I am able to get a token like this -

$customToken = $this->_userHelper->generateResetPasswordLinkToken();
$reset_password_link = $baseUrl.'customer/account/createpassword/?token='.$customToken;

but when click then getting a message like this "Reset password link has expired"

1
  • Did you got the solution?
    – Mohit Rane
    Commented Feb 2, 2023 at 6:43

2 Answers 2

1

Are you trying to access the link outside of your configured lifetime?

Stores -> Configuration -> Customer Configuration -> Password Options -> Recovery Link Expiration Period (hours)

Increase this number

1
  • yes,i am using outside to access Commented Jun 17, 2019 at 8:30
0

Try this way to fetch the correct token of the user

<?php
namespace Vendor\Module\Controller\Index;
use Magento\Customer\Model\CustomerRegistry;
class Test
{
    const PATH_RESET_PASSWORD='customer/account/createPassword/?token=';
    public function __construct(
        CustomerRegistry $customerRegistry,
        \Magento\Store\Model\StoreManagerInterface $storemgr
                   )
    {
        $this->customerRegistry = $customerRegistry;
        $this->_storeManager= $storemgr;
    }

    public function execute()
    {
                $Token=$this->customerRegistry->retrieveSecureData('CustomerId i.e 3')->getData('rp_token');
                echo "link::<br>".$this->_storeManager->getStore()->getBaseUrl().self::PATH_RESET_PASSWORD.$Token;

       }


    }

if this doesn't work then try to increase Recovery Link Expiration Period from configuration.

1
  • i tried this but not working Commented Oct 9, 2019 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.