magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Breaking change and incorrect docs for `AccountManagement::resetPassword` in 2.4.3-p2+ #35726

Open kardeiz opened 2 years ago

kardeiz commented 2 years ago

Preconditions and environment

Steps to reproduce

Post an empty string ('') as the email parameter to POST /customers/resetPassword API endpoint.

Expected result

Expected service returns 200 OK, with password reset appropriately.

Actual result

Endpoint will respond with 400:

{
    "message": "\"%fieldName\" is required. Enter and try again.",
    "parameters": {
        "fieldName": "email"
    }
}

The 2.4.3-p2 docs suggest that an empty email will be replaced by lookup via the resetPassword token:

https://github.com/magento/magento2/blob/1dd4ee8c3ab26dbb762fbaf9893c1f75148bb35b/app/code/Magento/Customer/Api/AccountManagementInterface.php#L146-L158

However, looking at the actual implementation, this does not appear to be the case: it is now set to throw the error above:

https://github.com/magento/magento2/blob/1dd4ee8c3ab26dbb762fbaf9893c1f75148bb35b/app/code/Magento/Customer/Model/AccountManagement.php#L714-L721

This is a pretty major change from 2.4.3-p1:

https://github.com/magento/magento2/blob/8afdb9858d238392ecb5dbfe556068ec1af137bc/app/code/Magento/Customer/Model/AccountManagement.php#L714-L721

And it is completely breaking our reset password functionality for users.

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @kardeiz. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Delta commented 2 years ago

Hi @kardeiz , Thanks for raising an issue , Need help on the request body that you have tried , so that we can replicate it .

In fact , we have tried below request but getting different error.

Request: { email: "roni_cost@example.com", resetPasswordToken: "gh80pkjGdsPyiXc0sUUXswX1uGN7crUr", newPassword: "new_password"

}

Response: { "message": "Decoding error." }

kardeiz commented 2 years ago

Our request body looks like:

{
    "newPassword": "newPassword",
    "resetToken": "resetToken",
    "email": ""
 }

Note the empty string for email. As far as I can tell, the token key is still resetToken not resetPasswordToken in 2.4.3-p2 (and possibly 2.4.4).

engcom-Delta commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Delta, here is your Magento Instance: https://bcc07cc7637dfb43007c5b939dc1efd1.instances.magento-community.engineering Admin access: https://bcc07cc7637dfb43007c5b939dc1efd1.instances.magento-community.engineering/admin_65c1 Login: 860ff713 Password: 7924e30c23f4

engcom-Delta commented 2 years ago

Hi Kardeiz, We tried to reproduce the issue on magento 2.4 develop , issue is reproducible , Hence issue has been confirmed.

followed steps:

  1. Run below API

Endpoint----->. PUT --> http://localhost/rest/default/V1/customers/password Body: { "email": "teslatester@gmail.com", "template": "email_reset" }

Response: true

  1. Run below API Endpoint----->. POST --> http://localhost/rest/default/V1/customers/resetPassword

Body: { "email": "", "resetToken": "00:3:yy/6Rj33nHPHL+mpHTWp6dlHUqtzVNNA0bTUG1PqsfRBJxcLiLHAwr77xQTQprpyijY6V5Fs/rP+AWXf", "newPassword":"Tester@321" }

Response: { "message": "\"%fieldName\" is required. Enter and try again.", "parameters": { "fieldName": "email" }, "trace": "#0 /opt/homebrew/var/www/magento24d3/magento2/generated/code/Magento/Customer/Model/AccountManagementApi/Interceptor.php(86): Magento\Customer\Model\AccountManagement->resetPassword('', '00:3:yy/6Rj33nH...', 'Tester@321')\n#1 [internal function]: Magento\Customer\Model\AccountManagementApi\Interceptor->resetPassword('', '00:3:yy/6Rj33nH...', 'Tester@321')\n#2 /opt/homebrew/var/www/magento24d3/magento2/app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#3 /opt/homebrew/var/www/magento24d3/magento2/app/code/Magento/Webapi/Controller/Rest.php(195): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))\n#4 /opt/homebrew/var/www/magento24d3/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#5 /opt/homebrew/var/www/magento24d3/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->callParent('dispatch', Array)\n#6 /opt/homebrew/var/www/magento24d3/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#7 /opt/homebrew/var/www/magento24d3/magento2/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->callPlugins('dispatch', Array, Array)\n#8 /opt/homebrew/var/www/magento24d3/magento2/lib/internal/Magento/Framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#9 /opt/homebrew/var/www/magento24d3/magento2/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()\n#10 /opt/homebrew/var/www/magento24d3/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()\n#11 /opt/homebrew/var/www/magento24d3/magento2/pub/index.php(31): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#12 {main}" }

screenshot

Screenshot 2022-07-22 at 6 13 47 PM

Despite of providing valid email id and valid reset_token , api is not working .

Screenshot 2022-07-22 at 6 23 50 PM
engcom-Delta commented 1 month ago

Hi @kardeiz ,

Thanks for your reporting and collaboration. We have verified the issue in latest 2.4-develop instance and the issue is reproducible. Kindly refer the screenshots.

Steps to reproduce -

  1. Post an empty string ('') as the email parameter to POST /customers/resetPassword API endpoint. image
  2. Now, Enter the email id and run the API image Observe without email user is not able to reset password

Thanks.

github-jira-sync-bot commented 1 month ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-13045 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 month ago

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.