Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My Account - Forgot Password #2619

Merged
merged 81 commits into from
Aug 25, 2020
Merged

Conversation

revanth0212
Copy link
Contributor

@revanth0212 revanth0212 commented Aug 10, 2020

Description

Implemented forgot password UX and workflow for the new my account feature.

For this PR I had to add a new route /customer/account/createPassword which provides the UX to reset the user's password.

When the user requests a password reset, the backend sends an email with a button to take the user to a new tab. The link that the backend includes in the email, uses the MAGENTO_BACKEND_URL as the domain. Since all the backends don't have the code to handle the new route /customer/account/createPassword, @dpatil-magento helped me deploy the new code on this server: https://staging-vdt2zeq-c5v7sxvquxwl4.eu-4.magentosite.cloud/. If someone wants to test this PR locally, please use the above backend URL instead.

Also if you wanna test this PR on a deployed instance please use #2621. @dpatil-magento made sure the backend for that PR is set to https://staging-vdt2zeq-c5v7sxvquxwl4.eu-4.magentosite.cloud/ which has the code to handle the new route.

Another way to test this is to paste the query string part from the email link next to the deployed app URL, for instance: https://pr-2619.pwa-venia.com/customer/account/createPassword/ + ?email=gooseton%40gmail.com&token=*******.

Sorry if this is confusing.

Note: To be merged only after #2590

Related Issue

Closes PWA-77

Acceptance

Users should be able to reset their password.

Verification Stakeholders

@soumya-ashok
@schensley
@jimbo

Specification

This PR adds a new route customer/account/createPassword which takes 2 query params ?email=EMAIL_ID&token=RESET_TOKEN.

Verification Steps

  1. Go to the deployed app and open the sign-in dropdown. Click on the forgot password link.
  2. Enter the email id and submit.
  3. Check for the reset email. Click the reset button in the email.
  4. Reset UI should open up in the new tab.
  5. Enter new password and click submit.

Screenshots / Screen Captures (if appropriate)

Demo link: https://jira.corp.magento.com/secure/attachment/367170/Forgot%20password%20demo.mp4

image

image

image

image

image

image

image

image

image

Checklist

  • I have added tests to cover my changes, if necessary.
  • I have updated the documentation accordingly, if necessary.

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Aug 10, 2020

Messages
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).
📖

Associated JIRA tickets: PWA-77.

Generated by 🚫 dangerJS against a7c62e6

@devops-pwa-codebuild
Copy link
Collaborator

devops-pwa-codebuild commented Aug 10, 2020

Performance Test Results

The following fails have been reported by WebpageTest. These numbers indicates a possible performance issue with the PR which requires further manual testing to validate.

https://pr-2619.pwa-venia.com : LH Performance Expected 0.85 Actual 0.33, LH Accessibility Expected 1 Actual 0.97, LH Best Practices Expected 1 Actual 0.93, WPT Cache Expected 90 Actual 38
https://pr-2619.pwa-venia.com/venia-tops.html : LH Performance Expected 0.75 Actual 0.35, LH Best Practices Expected 1 Actual 0.93
https://pr-2619.pwa-venia.com/valeria-two-layer-tank.html : LH Performance Expected 0.8 Actual 0.41, LH Accessibility Expected 0.9 Actual 0.89, LH Best Practices Expected 1 Actual 0.93, WPT Cache Expected 65 Actual 50

},
{
name: 'Reset Password',
pattern: '/customer/account/createPassword',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route can change. It is the route configured in the forgot password email template in the admin panel.

I don't think we have a setting for changing it without modifying the email template manually. Should we have this in the app config?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not sure how much we care about the preconfigured routes. I would also probably use hyphen instead of camelcase ie /customer/account/create-password.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the default route. If we happen to change this and someone forgets to change the template, the whole workflow fails. That is no reason to not change since someone configuring this should know for sure. I prefer your idea as well, hyphen case is correct in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe until such time that there is a M2 module for Magento Core that configures the front-end to be in line with PWA Studio expectations with a click of a button the default route should work.

If there was preference for something else maybe an upward rule could be added to redirect from the default to the PWA Studio expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fooman, I don't think UPWARD will be bothered in this case because the link from the email will directly hit the backend server. If we have runtime UPWARD rules, we can perform such kind of mapping. @zetlen any thoughts?

Link from the email would look something like this:

https://staging-vdt2zeq-c5v7sxvquxwl4.eu-4.magentosite.cloud/customer/account/createPassword/?email=EMAIL_ID&token=TOKEN

Copy link
Contributor

@fooman fooman Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@revanth0212 I do believe you might have stumbled on a bigger discussion here...

This link:
https://staging-vdt2zeq-c5v7sxvquxwl4.eu-4.magentosite.cloud/customer/account/createPassword/?email=EMAIL_ID&token=TOKEN
combined with running the upward php connector would result in this

https://github.com/magento/magento2-upward-connector/blob/develop/Plugin/Magento/Framework/App/AreaList.php#L50

making it an upward response (unless the route gets whitelisted, I am not sure that there is currently an option to whitelist a changeable url).

The other option I consider likely is that the back-end will be configured to send out an email like
https://venia.magento.com/customer/account/createPassword/?email=EMAIL_ID&token=TOKEN
(the base url can be changed for the complete site, whereas the /customer/account/createPassword part is in the individual email template) with a separate back-end url. In this scenario upward-js would handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if the admin panel has an option to store/change the main site URL / public URL for instance https://venia.magento.com/. If so, we can check to use that.

This is how the URL is generated in the email template:

<a href="{{var this.getUrl($store,'customer/account/createPassword/',[_query:[token:$customer.rp_token,email:$customer.email],_nosid:1])}}" target="_blank">{{trans "Set a New Password"}}</a>

Ill have to look into the implementation of the this.getUrl function to know what variables it is considering.

Copy link
Contributor

@fooman fooman Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@revanth0212 it is all configurable under Stores > Configuration > Web.

I guess the point I was trying to make is that upward is part of it one way or the other (upward-php or upward-js).

So if you wanted to have a route my-account/create-password then an upward rule could redirect from customer/account/createPassword/ to my-account/create-password to cover people using the default template.

sirugh
sirugh previously approved these changes Aug 24, 2020
@supernova-at
Copy link
Contributor

supernova-at commented Aug 24, 2020

QA

Verification Steps

Note: verification steps were performed on #2621 PR deployment.

  • Go to the deployed app and open the sign-in dropdown. Click on the forgot password link.
  • Enter the email id and submit.
  • Check for the reset email. Click the reset button in the email.
  • Reset UI should open up in the new tab.
  • Enter new password and click submit.

Other

Cannot Reset the Customer's Password

I entered an email that does not have an account and got the following error:

Screen Shot 2020-08-24 at 12 03 43 PM

This seems like a reasonable error message, my only concern is that we may be providing valuable information to a potential attacker. The standard message "If there is an account associated with EMAIL you will receive an email with a link to change your password" covers this error scenario and it might be better to show that message even when we get this error in the errors of the GraphQL response. That said, I know these are just strings and we don't want to hardcode english comparisons, so 🤷‍♂️

I should also note that I am assuming that the reason we got that error was because there was no account associated with that email address. Should probably check with the GraphQL team to make sure.

Stay on Reset Password Page

After resetting my password and signing in via the site header, I was never navigated away from the "Reset Password" page:

Screen Shot 2020-08-24 at 3 59 03 PM

I'm not quite sure what I'd want to happen instead, but it was a strange UX, especially after I signed in successfully. cc @schensley

@revanth0212
Copy link
Contributor Author

revanth0212 commented Aug 24, 2020

This seems like a reasonable error message, my only concern is that we may be providing valuable information to a potential attacker. The standard message "If there is an account associated with EMAIL you will receive an email with a link to change your password" covers this error scenario and it might be better to show that message even when we get this error in the errors of the GraphQL response.

If I remember correctly, the GQL team is working on updating their mutations to provide more reasonable/understandable error messages. It should be just a matter of time before they come up with a better error message for such use cases. That said, should we wait for them or render our own message? If we do it ourselves, it will be a standard message for any sort of an error from the server.

Also, even if we do that, it might still be subject to security because the attacker can simply check the network tab for the error reported from the server. What do you guys think?

@schensley
Copy link

@supernova-at

After resetting my password and signing in via the site header, I was never navigated away from the "Reset Password" page:

This isn't uncommon for reset pages, at least from my experience. I don't think we can predict where the user would like to be. Maybe they will sign in immediately, but do they intend to go to checkout, perform some Account management, or enable a personalized shopping experience? Arbitrarily navigating them to some page (i.e. Home page) could feel imposing or interpreted as presenting some workflow they think they must complete. Keeping them on a page that displays a Success message allows them to make that decision themselves.

@supernova-at
Copy link
Contributor

Also, even if we do that, it might still be subject to security because the attacker can simply check the network tab for the error reported from the server. What do you guys think?

Good point. I'm good keeping this as-is then, with the hopes that GQL error messages improve.

@supernova-at
Copy link
Contributor

Are there security concerns with having the customer email and a reset token in the URL?

@revanth0212
Copy link
Contributor Author

Are there security concerns with having the customer email and a reset token in the URL?

It is usual practice to include email and a token in the reset link. We can get away with not having the email in the link by adding another field on the page where the user can enter their email. But, token needs to be present in the link.

@sirugh
Copy link
Contributor

sirugh commented Aug 25, 2020

It is usual practice to include email and a token in the reset link. We can get away with not having the email in the link by adding another field on the page where the user can enter their email. But, token needs to be present in the link.

Is the link and params configurable in the back end? What is the default setting?

@revanth0212
Copy link
Contributor Author

Is the link and params configurable in the back end? What is the default setting?

Yeah, link and params are configurable. We are using the default link which is customer/account/createPassword. The email template by default only has the logic to include the token in the email, but due to the UX requirements, we had to add the email id as well.

@tjwiebell
Copy link
Contributor

tjwiebell commented Aug 25, 2020

... but due to the UX requirements, we had to add the email id as well.

This is also a technical requirement, the GraphQL mutation requires token, email, and new password.

@revanth0212
Copy link
Contributor Author

... but due to the UX requirements, we had to add the email id as well.

This is also a technical requirement, the GraphQL mutation requires token, email, and new password.

Yes, you are right but UX wanted the user to click the link, enter new password and submit. Hence we had to change the email template to include email id as well.

@sirugh
Copy link
Contributor

sirugh commented Aug 25, 2020

The email template by default only has the logic to include the token in the email, but due to the UX requirements, we had to add the email id as well.

Are you saying that you customized your back end to include email in the reset link that is sent to the user? Was the UX requirement not to have an email input field?

I would be cautious about customizing the default link - it would be preferable to leave it as is so pwa studio just works out of the box.

If we absolutely must stick to this UX then can you create a follow up ticket to have @jcalcaben update the "getting started" steps and whatever documentation is necessary?

My instinct is to have an email entry field and a new password field and to not customize the link.

@supernova-at supernova-at merged commit b942aff into develop Aug 25, 2020
@supernova-at supernova-at deleted the revanth/my_account_forgot_password branch August 25, 2020 21:18
@abso-bmarquis
Copy link

Hi @supernova-at,

I believe this code was removed accidentally when merging this PR: #2657
I don't see the feature on any of the current tags.

Please advise.
Regards,
Ben

@dpatil-magento
Copy link
Contributor

HI @abso-bmarquis,

Latest PR related to forgot password refactor is #2726.

Thanks,
Dev

@abso-bmarquis
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:peregrine pkg:venia-ui version: Major This changeset includes incompatible API changes and its release necessitates a Major version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants