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

Headless WooCommerce: auto-register & login on checkout #6

Open
luisherranz opened this issue Nov 25, 2019 · 0 comments
Open

Headless WooCommerce: auto-register & login on checkout #6

luisherranz opened this issue Nov 25, 2019 · 0 comments

Comments

@luisherranz
Copy link
Member

Another edgy case of WordPress auth flow, but quite common, is the automatic register and login of a new user during the WooCommerce checkout.

Once this option is active:

Screen Shot 2019-11-25 at 10 36 49

Users only need to provide an email and place the order:

WooCommerce - Checkout

Then, once the order is finished users are automatically logged in, and can see their order, downloads and so on:

WooCommerce - Order Received

They also receive an additional email with their new account and password:

WooCommerce - Welcome Email


This would obviously get out of the scope of the OAuth 2 auth method but, as the final token is likely to be a JWT, I wonder if a function could be exposed so other plugins can generate the JWT themselves.

If that's the case, the Headless WooCommerce could work like this:

  • User places an order in the Headless frontend. Data is sent to some new-order endpoint.
  • WooCommerce receives order via the new-order endpoint, creates the user, generates the JWT (using the exposed function) and returns everything in the response.
  • Headless frontend receives the JWT and the user is logged in.

What I don't know is if exposing such a function would mean a security risk. Any thoughts?

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

No branches or pull requests

1 participant