This is a follow up to #2847708: RPC endpoint to reset user password and just adding it for discussion.
I was hoping to submit a patch for this but I found that this will require a bit of rework as how _skipProtectedUserFieldConstraint is worked in the workflow will likely either need duplication or some proper planning on how to rework.
I wonder if the validation of a password reset token should be added to the actual ProtectedUserFieldConstraint instead of outside.
In the meantime, I worked on an alternative to this on https://www.drupal.org/sandbox/hanoii/2904436
It should work for both 8.3.x and 8.4.x.
| Comment | File | Size | Author |
|---|
Issue fork drupal-2904451
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hanoiiComment #3
wim leersSounds like a sensible feature request :)
Comment #4
wim leersLeft a comment at #2403307-295: RPC endpoints for user authentication: log in, check login status, log out to people who were on the original issue aware of this follow-up.
Comment #7
wim leersComment #10
joao sausen commentedThis patch has some security issues.
Same thing as https://www.drupal.org/project/drupal/issues/1521996
Comment #12
bradjones1Comment #16
andypostComment #17
andypostComment #19
skyredwangHere is the first draft, no tests. I am reusing the /user/password endpoint, if the HTTP method is POST, then this implementation assume it is for resetting password, if the HTTP method is PATCH, then it is for changing password.
Comment #20
_utsavsharma commentedAs previous patch failed , patch for 11.x.
Comment #21
alexpottOnce the patch request is a separate route you can make this a route requirement.
No form state here.
Let's add a different route for just patch. And let it have it's own controller. I don;t think we shoudl be renaming resetPassword here. And I think having a separate changePassword method is okay.
We can refactor the common parts of both methods into private functions on the controller.
Comment #22
skyredwangThe reason I didn't want to use a seperate controller is because the existing resetPassword uses
/user/password./user/passwordis generic, if I use a new path like/user/change_passwordfor changing password, then we have two end points for the consumer. One generic, one specific, that's confusing to me. What do you think?Attached improved the code comment per suggestion 2
Comment #23
skyredwangCorrected the patch path
Comment #24
bradjones1Re-queued the patch since it's against 11.x but DrupalCI was running it against 10.1.
Also just want to say I love that this is using HTTP verb semantics to determine the operation to be performed!
Comment #25
skyredwangI spoke with @alexpott on Slack, and understood that I can keep the same endpoint but defining a new route based on the new HTTP method. So, I agree with his suggestions.
I pushed the change to the issue fork 11.x
Comment #27
smustgrave commentedHiding patches as work is in a MR with correct branch.
But appears to have some failures.
Comment #28
skyredwangThe lastest version is functioning. It supports two use cases:
- Change password knowing the existing password
- Change password without knowing the existing password, but have the timestamp and token from forget password URL
Remaining work to do:
- Tests
- Some of the code are copied from /core/modules/user/src/AccountForm.php and /opt/drupal/web/core/modules/user/src/Controller/UserController.php , better to re-organize them, but need suggestions, as I am not familiar with core.
Comment #29
smustgrave commentedPassed tests, just needs it's own coverage as mentioned.