0

I am trying to reset password from forgot password action using REST API:

http://domain/index.php/rest/V1/customers/password?
email=myemail@gmail.com&
template=email_reset&
websiteId=1

and I receive an email successfully to set new password as follow:

enter image description here

When click the button Set a New Password, I got this error

Your password reset link has expired

as follow :

enter image description here

when enter my email again in the last screen, I got another email to reset a new password as the first image, then click reset password and I can receive the proper screen and reset password function working fine as follow :

enter image description here

2

First of all thanks @Shireen your comments help me to debug. I have kind of similar issue and it resolved not in the best way.

@Jsparo30

when you request reset password link via API, Magento creates DirectLink(Link with the query string, has 2 params) which are as follows.

please check this file /vendor/magento/module-customer/Controller/Account/CreatePassword.php

enter image description here and when you click the button on reset password email Magento try to access those query string params and get Failedenter image description here

due to they accessing the wrong param.

to overcome this problem quickly all you need to just replace param token with amp;token

I know this is not the solution, but you can at least start with this.

1

You are getting some magento exception. To check what is that exception, go to class method

Magento\Customer\Controller\Account\CreatePassword::execute()

and in catch statement log the exception like die($exception);

  • 1
    Thanks, This is the exception I got. How can I fix ? Magento\Framework\Exception\InputException: Invalid value of "0" provided for the customerId field. in /opt/bitnami/apps/magento/htdocs/vendor/magento/module-customer/Model/AccountManagement.php:933 Stack trace: #0 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-customer/Model/AccountManagement.php(490): Magento\Customer\Model\AccountManagement->validateResetPasswordToken(0, '') #1 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-customer/Controller/Account/CreatePassword.php(63) – Jsparo30 Feb 6 '18 at 6:47
  • If you want to change the password of the customer by which you are logged in then you can also use this api - domain/index.php/rest/V1/customers/me/password? or also try passing customer id in the api which you are currently using or may be you are using the wrong email id – Shireen N Feb 6 '18 at 7:10
  • where I can pass the customer id ? – Jsparo30 Feb 6 '18 at 7:12
  • Go to class method Magento\Customer\ModelAccountManagement::\initiatePasswordReset and print_r($customer->getData()) after line# 513. Check if you are getting any data, if not then you are using an email id which does not exists in magento DB – Shireen N Feb 6 '18 at 7:16
  • This API domain/index.php/rest/V1/customers/me/password? is using for update password and user is logged (he needs to just update). but I am talking about forgot password case. where I can pass the customer id as you mentioned in the second part of your answer. Thx. – Jsparo30 Feb 6 '18 at 7:17
0

I've had a similar problem. If you check the class AccountManagement (located: vendor/magento/module-customer/Model/AccountManagement.php).

You will find this was changed in 2.2.6. In my case an extension had copied the entire class to there extension which is now out of date and because of this throws an exception. Chances are that bitnami have done the same and they need to update there extension to be 2.2.6 compliant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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