-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix: Make new order email links correct for storefront #5251
Conversation
- Added an array of anonymous access tokens for this purpose Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
40d7853
to
4f6e6ed
Compare
One issue we are dealing with here seems to be stemming from the When an order is created, if you are an anonymous user (i.e. not logged into your account), the order is created with the following:
If you are logged in, it's the opposite:
This makes sense for anonymous users. For logged in users, we need to think about why we aren't saving an When an order email is sent out, the hashed If you remove the code from the URL, you'll see the order summary page works fine, because we are now skipping the I'm not sure the reasoning behind not saving the If there is no reason behind that, I think the simplest solution would be to add the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks wonderful @focusaurus . Just a few small things I noticed.
Reviewed code only. I'll let @kieckhafer test.
imports/plugins/core/orders/server/no-meteor/queries/orderByReferenceId.js
Outdated
Show resolved
Hide resolved
imports/plugins/core/orders/server/no-meteor/util/anonymousToken.js
Outdated
Show resolved
Hide resolved
imports/plugins/core/orders/server/no-meteor/util/getDataForOrderEmail.js
Outdated
Show resolved
Hide resolved
- Allow storefrontUrls to be missing (headless mode) - Avoid DB operation unless ":token" placeholder is present Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
@kieckhafer I think I'm going to rework the logic to deal with permissions from most-privileged to least-privileged and I think it will work. Testing locally now.
|
- Allows storefront URLs to work even signed in and have token Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
…ioncommerce/reaction into fix-pete-email-link-to-order-page
@focusaurus Your solution seems like it will work, but the comment from @kieckhafer reminds me that really we have no reason to generate the token upon sending the email if it's an order with @kieckhafer points out that making them less secure might be desirable if you want to share the link, but I think that's an edge case and I'd prefer if there is no way to access an account order unless you're logged in as that account. So the upshot of all that is that, when generating the |
OK @aldeed updated to not generate a token if |
Also add some more test cases Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
…ioncommerce/reaction into fix-pete-email-link-to-order-page
@manueldelreal Can you help us out with some testing on this please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Seems to work as it should: Anon orders provide a token, and the order is correctly displayed. Logged in orders to not provide a token, and the correct order is displayed.
Signed-off-by: Erik Kieckhafer <ek@ato.la>
@manueldelreal @aldeed this all looks good to me, I've signed off. I added some help text, so please look over that, but then feel free to merge when you give it the OK. |
Signed-off-by: Erik Kieckhafer <ek@ato.la>
Signed-off-by: Erik Kieckhafer <ek@ato.la>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@focusaurus Changes look good but I just remembered there are 4 types of order emails with different templates for each, but they all have {{homepage}}{{orderUrl}}
and need that same change. All 4 files in the same templates/orders
folder.
The issue was about the "new order" email, but all order emails actually had the same incorrect link in them.
@aldeed @focusaurus
is all that is needed here? |
Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
…ioncommerce/reaction into fix-pete-email-link-to-order-page Signed-off-by: Peter Lyons <pete@reactioncommerce.com>
@willopez Yes. I just pushed a commit that takes care of that. |
Resolves #4679
Impact: breaking|minor
Type: bugfix
Issue
New Order confirmation email was not updated yet to deal with storefront and core being on separate URLs yet.
Solution
We use the recently-added shop
storefrontUrls
settings to build the URL and pass that to the email template for rendering.One complication we hit is dealing with access tokens for anonymous orders. We don't store them, only their hash, so while we can navigate to their order confirmation page immediately, later when we go to render their order confirmation email, we don't have the raw token. So we decided to generate a new one at that time which required a schema change so an order can now have an array of access tokens. Typically there will be one from when the order was placed via storefront and one from when the order confirmation email was rendered and sent.
Breaking changes
The new order confirmation email template has been updated. The new code is here but we also write these to mongodb so they can be edited in the GUI. There is no migration for that data. It would have some extra complexity to determine if the data had been modified or not. Here's the diff if anyone wants to apply manually:
A migration was created and tested for the schema change.
Testing
http://storefront.reaction.localhost:4000/checkout/order/:orderId?token=:token
http://storefront.reaction.locahost:4000
66
(you should see this in the startup logs for reaction core)