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

Fix checkout login permissions #2752

Merged
merged 18 commits into from
Sep 14, 2017
Merged

Fix checkout login permissions #2752

merged 18 commits into from
Sep 14, 2017

Conversation

desaawa
Copy link
Contributor

@desaawa desaawa commented Aug 28, 2017

This resolves #2657

Steps to test

  1. Checkout without logged in and click "Continue as Guest" in first step. The "Welcome, it's so good to see you." message will be displayed and go to 2nd step.(checkoutLoginCompleted returned true)
  2. Checkout and Signin in the first step. The "Welcome, it's so good to see you." message will be displayed and go to 2nd step.(checkoutLoginCompleted returned true).

@impactmass
Copy link
Contributor

Works as described in your steps. But when I register as a new user, the step 1 of checkout doesn't seem to recognize that someone is logged in. Can you confirm this?
screenshot 2017-08-28 14 19 29

Copy link
Contributor

@impactmass impactmass left a comment

Choose a reason for hiding this comment

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

the register issue and the comment


if (currentStatus !== self.template && guestUser === true && anonUser === false) {
// when user is guest, they are also anonymous.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you describe this better? i.e to explain what the check below it does?

Seeing when user is guest, they are also anonymous doesn't particular help a reader to understand why we do this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@impactmass I have fixed the changes you requested, and updated the comments. Please confirm it works well now

@impactmass
Copy link
Contributor

There's an error from the Circle CI tests. can you confirm why it failed?

@desaawa
Copy link
Contributor Author

desaawa commented Aug 28, 2017

@impactmass they're passing now.

@aaronjudd aaronjudd self-requested a review August 29, 2017 00:25
@@ -17,10 +16,9 @@ Template.checkoutLogin.helpers({
const cart = Cart.findOne();
if (cart && cart.workflow) {
const currentStatus = cart.workflow.status;
const guestUser = Reaction.hasPermission("guest", Meteor.user());
const anonUser = Roles.userIsInRole("anonymous", Meteor.user(), Reaction.getShopId());
const guestUser = Reaction.hasPermission("guest", Meteor.userId(), Reaction.getShopId());
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need Meteor.userId() and getShopId(), those are supplied as default.

I worry about wether you should get rid of the permission check of "guest" and "anonymous". I suspect this will have unexpected consequences in the order/completed page, and if you register a user in the Accounts UI-> not being in the checkout flow.

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 had to remove it because when clicking to continue as guest, the user still has the anonymous permission. So if we are checking to ensure that they are not anonymous, it fails. So that's why I just check if they are guest alone.

Copy link
Contributor

@aaronjudd aaronjudd Aug 30, 2017

Choose a reason for hiding this comment

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

When you click as "continue as guest" you ARE still anonymous. you are only NOT anonymous if you have supplied an email, such as when you add an email at the order/completed stage. (at least that's how I remembered it, you might want to look closely at that and review other parts where this logic is used to verify)

Copy link
Contributor Author

@desaawa desaawa Aug 30, 2017

Choose a reason for hiding this comment

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

Yes that is how it is, but we were preventing anonymous users from "continuing as guest". which is why I removed the permission for anonymous. I will retest and comment guest vs anonymous login view behavior as requested.

@aaronjudd aaronjudd removed the request for review from brent-hoover August 29, 2017 00:36
Copy link
Contributor

@aaronjudd aaronjudd left a comment

Choose a reason for hiding this comment

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

Retest and comment guest vs anonymous login view behavior. Implement hasPermissions, don't supply params that are defaults.

@desaawa
Copy link
Contributor Author

desaawa commented Sep 5, 2017

@aaronjudd I updated the comments. Please take a look.

@aaronjudd
Copy link
Contributor

See #2328 as well, may be related

@brent-hoover
Copy link
Collaborator

@aaronjudd Is there more to do on this? Should I have someone else pick it up or are we close to merging?

@aaronjudd
Copy link
Contributor

@rymorgan Note, while we closed this -> one side affect / repercussion -> the inline login in the checkout is supposed to show "REGISTER" as the default view, while the dropdown is supposed to show "SIGN IN" as the default view.

@rymorgan
Copy link
Contributor

@aaronjudd Got it. I've made an issue to correct it. #2944

@spencern spencern mentioned this pull request Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants