Skip to content

F51-214, F51-222 Anonymous Shopping#90

Merged
crhistianramirez merged 6 commits intoordercloud-api:developmentfrom
robertsoniv:development
May 17, 2017
Merged

F51-214, F51-222 Anonymous Shopping#90
crhistianramirez merged 6 commits intoordercloud-api:developmentfrom
robertsoniv:development

Conversation

@robertsoniv
Copy link
Contributor

@robertsoniv robertsoniv commented May 17, 2017

Summary of changes:

  • When app.constants.json > anonymous is set to true, the ocRefreshToken service will attempt to authorize anonymously using the current clientid and scope constants.
  • An error will be logged to the console if the clientid is not configured to work with anonymous authentication.
  • Do not store anon refresh tokens: storing these tokens will trigger the refresh token workflow which does not correspond to an anonymous authentication.
  • Comments have been added in the code explaining why we do not store the refresh tokens from the anonymous auth response.
  • The /register component has been added. Anonymous users can access this at any time to profile themselves.
  • The login.controller.js has been updated to merge anon orders with profiled users most recent unsubmitted order
  • Checkout state has a resolve for opening up the ocAnonymous.Identify() modal which will force anon users to either login or register before continuing to checking out.
  • ocAnonymous has a "Redirect" function for sending the newly profiled user to the state that was passed into the ocAnonymous.Identify() modal (usually "cart" but it could be anything)
  • Remove the redirect cookie after a successful ocAnonymous.Redirect()
  • Block the registration state from non-anonymous users & applications
  • Fix undefined error blocking ocStateLoading from completing
  • Add a redirectState argument to ocRefreshToken(redirectState) for controlling where the user is sent to after the new token is retrieved.
  • Registration form validation for username conflicts.

See the commit messages for more details.

Additional tasks:
F51-236 - Allow duplicate toasts on add-to-cart

- When app.constants.json > anonymous is set to true, the ocRefreshToken
  service will attempt to authorize anonymously using the current clientid
  and scope constants.
- An error will be logged to the console if the clientid is not configured
  to work with anonymous authentication.
- Storing these tokens will trigger the refresh token workflow
  which does not correspond to an anonymous authentication.
- Comments have been added in the code explaining why we do not
  store the refresh tokens from the anonymous auth response.
- The /register component has been added. Anonymous users can
  access this at any time to profile themselves.
- The /login controller has been updated to merge anon orders
  with profiled users most recent unsubmitted order
- Checkout state has a resolve for opening up the ocAnonymous
  Identify modal which will force anon users to either login or
  register before continuing to checking out.
- ocAnonymous has a "Redirect" function for sending the newly
  profiled user to the state that was passed into the .Identify()
  modal (usually "checkout.shipping" but it could be anything)
- Redirect back to cart after force profiling
- Remove the redirect cookie after a successful ocAnonymous.Redirect()
- Block the registration state from non-anonymous users & applications
- Fix undefined error blocking ocStateLoading from completing
- Add a redirectState argument to ocRefreshToken() for controlling where
  the user is sent to after the new token is retrieved.
- Registration form validation for username conflicts.
@robertsoniv
Copy link
Contributor Author

I confirmed the login unit tests are still passing. I will create tasks for unit testing the common/services/oc-anonymous directory.

<div class="panel-footer">
<button ng-if="cart.lineItems.Items.length > 0" type="button" ui-sref="checkout.shipping" class="btn btn-block btn-primary" ng-disabled="OrderLineItemForm.$invalid">Proceed to Checkout</button>
<button ng-if="cart.lineItems.Items.length > 0" type="button" ng-click="cart.proceedToCheckout()" class="btn btn-block btn-primary" ng-disabled="OrderLineItemForm.$invalid">Proceed to Checkout</button>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you have an ng-click here? Looks like its just routing user to checkout.shipping state, so we can probably just keep the ui-sref?

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 thought about removing it, but while developing it took me a second to figure out why my click wasn't updating and that's because we have TWO proceed to checkout buttons (one only displays on mobile views).

I think leaving this as a function will help future developers alter the proceedToCheckout behavior in a way that doesn't require them to know anything about the template.

ocMatch: 'Passwords do not match.',
positiveInteger: 'Please enter a positive integer',
ID_Name: 'Only Alphanumeric characters, hyphens and underscores are allowed',
confirmpassword: 'Your passwords do not match',
Copy link
Contributor

Choose a reason for hiding this comment

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

Reuse confirmPassword error message instead of creating a new one with the same content.

};
}
};
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

we also have a confirm-password directive that does the same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I like the way this is structured better than the confirmPassword directive. It's a lot less code and it actually creates a $ngModelCtrl validator.

I don't believe the confirmPassword directive is being used anywhere in the app so maybe we can create a task to remove that.

@crhistianramirez crhistianramirez merged commit 06f7332 into ordercloud-api:development May 17, 2017
crhistianramirez pushed a commit to Four51/demo-angular-buyer that referenced this pull request Aug 3, 2017
New and improved user group filtering on orders
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.

2 participants