[API] reseting password with validation#12391
Conversation
arti0090
commented
Mar 1, 2021
| Q | A |
|---|---|
| Branch? | master |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| License | MIT |
|
I have intentionally left comments with some changes (that tested on apiplatform v2.6) that will work when endpoint will be PATCH /request-reset-password/{token} At the moment it does not work. We first need support for that version. There should be also no issue with removing these comments as my last commit is pushed 2149e87 |
bb0a61d to
50384fb
Compare
50384fb to
c0a15e0
Compare
Co-authored-by: Adam Kasperczak <[email protected]>
| use Webmozart\Assert\Assert; | ||
|
|
||
| /** @experimental */ | ||
| final class ConfirmResetPasswordValidator extends ConstraintValidator |
There was a problem hiding this comment.
Missing spec for this class
| $userRepository->findOneBy(['passwordResetToken' => 'TOKEN'])->willReturn($shopUser); | ||
| $metadata->getParameter('resetting')->willReturn(['token' => ['ttl' => 'P5D']]); | ||
|
|
||
| $shopUser->isPasswordRequestNonExpired(Argument::that(function(\DateInterval $dateInterval ) { |
There was a problem hiding this comment.
| $shopUser->isPasswordRequestNonExpired(Argument::that(function(\DateInterval $dateInterval ) { | |
| $shopUser->isPasswordRequestNonExpired(Argument::that(function(\DateInterval $dateInterval) { |
Same below
| /** | ||
| * @When /^I follow link on (my) email to reset my password$/ | ||
| */ | ||
| public function iFollowLinkOnMyEmailToResetPassword(UserInterface $user): void |
There was a problem hiding this comment.
| public function iFollowLinkOnMyEmailToResetPassword(UserInterface $user): void | |
| public function iFollowLinkOnMyEmailToResetPassword(ShopUserInterface $user): void |
?
| public function getResetPasswordToken(): string | ||
| { | ||
| return $this->resetPasswordToken; | ||
| } | ||
|
|
||
| public function setResetPasswordToken(string $token): void | ||
| { | ||
| $this->resetPasswordToken = $token; | ||
| } |
There was a problem hiding this comment.
Are these methods needed as $resetPasswordToken has public access?
| } | ||
|
|
||
| if ($command->getResetPasswordToken() !== $user->getPasswordResetToken()) { | ||
| throw new \InvalidArgumentException('Password reset token do not match.'); |
There was a problem hiding this comment.
| throw new \InvalidArgumentException('Password reset token do not match.'); | |
| throw new \InvalidArgumentException('Password reset token does not match.'); |
| throw new \InvalidArgumentException('Password reset token do not match.'); | ||
| } | ||
|
|
||
| $user->setPlainPassword($command->newPassword); |
There was a problem hiding this comment.
Do you check somewhere the new password with the password confirmation?
| <attribute name="messenger">input</attribute> | ||
|
|
||
| <collectionOperations> | ||
| <collectionOperation name="shop_password_reset_request"> |
There was a problem hiding this comment.
| <collectionOperation name="shop_password_reset_request"> | |
| <collectionOperation name="shop_request_reset_password"> |
| </collectionOperations> | ||
|
|
||
| <itemOperations> | ||
| <itemOperation name="shop_password_reset"> |
There was a problem hiding this comment.
| <itemOperation name="shop_password_reset"> | |
| <itemOperation name="shop_reset_password"> |
| <attribute name="groups">shop:reset_password:update</attribute> | ||
| </attribute> | ||
| <attribute name="openapi_context"> | ||
| <attribute name="summary">Password reset</attribute> |
There was a problem hiding this comment.
| <attribute name="summary">Password reset</attribute> | |
| <attribute name="summary">Resets password</attribute> |
to be consistent with other endpoints
| <attribute name="groups">shop:reset_password:create</attribute> | ||
| </attribute> | ||
| <attribute name="openapi_context"> | ||
| <attribute name="summary">Request password reset</attribute> |
There was a problem hiding this comment.
| <attribute name="summary">Request password reset</attribute> | |
| <attribute name="summary">Requests password reset</attribute> |
|
Thank you, @arti0090! 🎉 |
…ord PR (arti0090) This PR was merged into the 1.10-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | License | MIT Continuation of #12391 Commits ------- 08adcf3 add missing specs and make fixes to reset password PR
This PR was merged into the 1.10-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT Continuation of #12391 <!-- - Bug fixes must be submitted against the 1.7 or 1.8 branch (the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> Commits ------- 2fdd995 [API] Adjust reset password requests