=== Sign in with Google for WooCommerce by Teck Form ===
Contributors: teckform
Tags: google login, social login, woocommerce, sign in with google, oauth
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A "Continue with Google" button for WooCommerce login, registration and checkout. Secure OAuth 2.0 with PKCE; customers are created automatically.

== Description ==

Let customers sign in or register with their Google account in one click.

The button appears on:

* the WooCommerce My Account login and registration forms
* the checkout "Returning customer? Click here to login" form
* wp-login.php
* anywhere else with the shortcode `[google_login_button]` (works inside Elementor and other page builders)

**How accounts are matched**

1. An account already connected to this Google account signs in directly.
2. An existing customer with the same verified email address is connected to Google and signed in.
3. Otherwise a new WooCommerce customer is created (the normal WooCommerce "new account" email is sent), unless you switch automatic registration off.

Google email addresses that Google has not verified are refused.

**Security**

* OAuth 2.0 / OpenID Connect authorization code flow with PKCE (S256) and a server-side, single-use `state`.
* The ID token's issuer, audience, nonce, subject and expiry are checked.
* Accounts that can manage the site (administrators, shop managers, editors, authors) are **not** connected to Google automatically by email, because a Google sign-in skips the password form and therefore two-factor and login-limit plugins. Developers can allow it with the `glwc_link_privileged_by_email` filter.
* An account that is connected to one Google account cannot be taken over by another Google account with the same email address.
* Only WordPress and WooCommerce hooks are used; no WooCommerce file is modified.

**Works with**

* **Amelia Booking**: new Google accounts also get an Amelia customer, and an earlier guest booking with the same (Google-verified) email is connected instead of duplicated.
* **Email Verification for WooCommerce**: accounts created through Google are marked verified immediately, because Google already verified the address.

== External services ==

This plugin connects to Google to sign people in. Nothing is sent to Google until a visitor clicks the "Continue with Google" button.

* **Google account sign-in** (`accounts.google.com`): the visitor's browser is sent there to choose a Google account. Google receives the site's Client ID, the return address and the requested permissions (openid, email, profile).
* **Google token endpoint** (`oauth2.googleapis.com`): your server exchanges the one-time code for tokens, sending the Client ID, Client Secret and code.
* **Google user info** (`openidconnect.googleapis.com`): your server reads the visitor's Google ID, email address, whether it is verified, name and profile picture.
* **Google profile pictures** (`lh3.googleusercontent.com`): when "Use the Google profile picture as the user avatar" is on, avatars are loaded from Google in visitors' browsers.

Google's terms: https://policies.google.com/terms
Google's privacy policy: https://policies.google.com/privacy

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. In the Google Cloud Console (https://console.cloud.google.com/), create or select a project.
3. Google Auth Platform > Branding: add your app name, support email and domain. Under Audience choose External and publish the app (otherwise only test users can sign in).
4. Google Auth Platform > Clients > Create client: choose "Web application" and add the Authorized JavaScript origin and the Authorized redirect URI shown on the plugin's settings page (WooCommerce > Google Login).
5. Copy the Client ID and Client Secret into WooCommerce > Google Login and save.
6. Log out and open My Account: the button appears under the login form.

Optional: instead of storing the credentials in the database, define `GLWC_GOOGLE_CLIENT_ID` and `GLWC_GOOGLE_CLIENT_SECRET` in wp-config.php.

== Frequently Asked Questions ==

= Can administrators sign in with Google? =

Not automatically. For security, an account that can manage the site is never connected to Google just because the email address matches. Administrators should sign in with their password (and two-factor, if you use it).

= Where does the button go in Elementor? =

Add a Shortcode widget with `[google_login_button]`. Options: `text`, `redirect` and `divider`, for example `[google_login_button text="Sign in with Google" redirect="/my-account/"]`. It shows nothing to visitors who are already logged in.

= Does it modify WooCommerce? =

No. It only uses WordPress and WooCommerce hooks, so WooCommerce updates do not break it.

= What is removed when I delete the plugin? =

Its settings, its temporary sign-in data and the Google connection stored on user accounts. The user accounts themselves are kept.

== Changelog ==

= 1.3.0 =
* Security: accounts that can manage the site are no longer connected to Google automatically by email (filter `glwc_link_privileged_by_email` to allow it).
* Security: an account already connected to one Google account cannot be taken over by a different Google account.
* Security: the ID token is now required and its expiry is checked.
* Privacy: email addresses are no longer written to the log.
* Fix: the button no longer shows on registration forms when automatic registration is off.
* Fix: saving the settings with unexpected input no longer causes a PHP error.
* Renamed to "Sign in with Google for WooCommerce by Teck Form" (folder `teckform-google-login`). Settings are kept. Deactivate the old "Google Login for WooCommerce" before activating this version.
* Uninstall now also cleans up every site of a multisite network.

= 1.2.0 =
* New: works with Email Verification for WooCommerce. Accounts created through Google are marked verified.

= 1.1.0 =
* New: Amelia Booking customer for every new Google account.

= 1.0.0 =
* Initial release.
