WP-API / authentication

The home for design & development of a core WordPress REST API authentication solution
GNU General Public License v2.0
62 stars 2 forks source link

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

Open luisherranz opened 4 years ago

luisherranz commented 4 years ago

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:

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