Skip to content

Commit

Permalink
Merge pull request #127 from rtCamp/feature/release-1.3.1
Browse files Browse the repository at this point in the history
Release 1.3.1
  • Loading branch information
abhishekfdd authored Oct 7, 2022
2 parents 326b759 + 684e1f1 commit 34ad185
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
1. [Overview](#overview)
2. [Installation](#installation)
3. [Usage Instructions](#usage-instructions)

[Plugin Constants](#plugin-constants)
[Hooks](#hooks)

4. [Shortcode](#shortcode)
5. [Minimum Requirements](#minimum-requirements)
Expand Down Expand Up @@ -37,19 +38,18 @@ passwords. Just one click and land into the site!

3. Once you create the app, you will receive the `Client ID` and `Client Secret`, add these credentials
in `Settings > Login with google` settings page in their respective fields.

4. `Create new user` enables new user registration irrespective of `Membership` settings in
`Settings > General`; as sometimes enabling user registration can lead to lots of spam users.
Plugin will take this setting as first priority and membership setting as second priority, so if
any one of them is enabled, new users will be registered by this plugin after successful authorization.

5. `Whitelisted Domains` allows users from specific domains (domain in email) to get registered on site.
This will prevent unwanted registration on website.
**For Example:** If you want users only from your organization (`myorg.com`) to get registered on the
website, you enter `myorg.com` in whitelisted domains. Users with google
email like `[email protected]` will be able to register on website. Contrary to this, users with emails like
`[email protected]` would not be able to register here.


### Plugin Constants

Expand All @@ -65,18 +65,43 @@ Refer following list of constants.
| WP_GOOGLE_LOGIN_USER_REGISTRATION | Boolean | (Optional) Set True If you want to enable new user registration. By default, user registration defers to `Settings > General Settings > Membership` if constant is not set. |
| WP_GOOGLE_LOGIN_WHITELIST_DOMAINS | String | (Optional) Domain name, if you want to restrict login with your custom domain. By default, It will allow all domains. You can whitelist multiple domains. |

These constants can also be configured
via [wp-cli](https://developer.wordpress.org/cli/commands/config/).
These constants can also be configured
via [wp-cli](https://developer.wordpress.org/cli/commands/config/).

**Note:** If you have defined the constant in wp-config.php file, corresponding settings field will be disable
(locked for editing) on the settings page.

### Hooks
#### Filters

| Filter | Description | Parameters |
| --- | ----------- | --- |
| `rtcamp.google_scope` | This filter can be used to filter existing scope used in Google Sign in. <br />You can ask for additional permission while user logs in. | <ul><li>`scope` - contains array of scopes.</li></ul>
| `rtcamp.google_login_modules` | Filter out active modules before modules are initialized. | <ul><li>`active_modules` - contains array of active modules.</li></ul>
| `rtcamp.google_login_button_display` | This filter is useful where we want to forcefully display login button, even when user is already logged-in in system. | <ul><li>`display` - contains a boolean value of whether to display the button or not.</li></ul>
| `rtcamp.google_default_redirect` | Filter the default redirect URL in case redirect_to param is not available. <br />Default to admin URL. | <ul><li>`admin_url` - contains the admin URL address which is used as redirect URL by default.</li></ul>
| `rtcamp.google_register_user` | Check if we need to register the user. | <ul><li>`user` - contains the user object from google.</li></ul>
| `rtcamp.google_client_args` | Filter the arguments for sending in query. <br />This is useful in cases for example: choosing the correct prompt. | <ul><li>`client_args` - contains the list of query arguments to send to Google OAuth.</li></ul>
| `rtcamp.google_login_state` | Filters the state to pass to the Google API. | <ul><li>`state_data` - contains the default state data.</li></ul>
| `rtcamp.default_algorithm` | Filters default algorithm for openssl signature verification | <ul><li>`default_algo` - Default algorithm.</li><li>`algo` - Algorithm from JWT header.</li></ul>

#### Actions

| Action | Description | Parameters |
| --- | ----------- | --- |
| `rtcamp.google_login_services` | Define any additional services. | <ul><li>`container` - Container object.</li></ul>
| `rtcamp.google_user_authenticated` | Fires once the user has been authenticated via Google OAuth. | <ul><li>`user` - User object.</li></ul>
| `rtcamp.id_token_verified` | Do something when token has been verified successfully.<br />If we are here that means ID token has been verified.
| `rtcamp.google_user_logged_in` | Fires once the user has been authenticated. | <ul><li>`user_wp` - WP User data object.</li><li>`user` - User data object returned by Google.</li></ul>
| `rtcamp.google_user_created` | Fires once the user has been registered successfully. | <ul><li>`uid` - User ID</li><li>`user` - WP user object.</li></ul>
| `rtcamp.login_with_google_exception` | Fires when an exception is raised during token verification. | <ul><li>`exception` - The exception which is being raised.</li></ul>

## Shortcode

You can add the google login button to any page/post using shortcode: `google_login`
You can add the google login button to any page/post using shortcode: `google_login`

**Example:**
```php
```php
[google_login button_text="Google Login" force_display="yes" /]
```

Expand Down Expand Up @@ -126,9 +151,9 @@ generated at `/tmp/report/html`

## Minimum Requirements

WordPress >= 5.4.0
WordPress >= 5.5.0

PHP >= 7.3
PHP >= 7.4

## License

Expand Down
12 changes: 6 additions & 6 deletions login-with-google.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* Plugin Name: Login with Google
* Description: Allow users to login/register via Google.
* Version: 1.3.0
* Version: 1.3.1
* Author: rtCamp
* Author URI: https://rtcamp.com
* Text Domain: login-with-google
* Domain Path: /languages
* License: GPLv2+
* Requires at least: 5.4.2
* Requires PHP: 7.3
* Requires at least: 5.5
* Requires PHP: 7.4
*
* @package RtCamp\GoogleLogin
* @since 1.0.0
Expand All @@ -30,15 +30,15 @@
];

/**
* PHP 7.3+ is required in order to use the plugin.
* PHP 7.4+ is required in order to use the plugin.
*/
if ( version_compare( PHP_VERSION, '7.3', '<' ) ) {
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
foreach ( $hooks as $hook ) {
add_action(
$hook,
function () {
$message = __(
'Login with google Plugin requires PHP version 7.3 or higher. <br />Please ask your server administrator to update your environment to latest PHP version',
'Login with google Plugin requires PHP version 7.4 or higher. <br />Please ask your server administrator to update your environment to latest PHP version',
'login-with-google'
);

Expand Down
26 changes: 9 additions & 17 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Contributors: rtCamp
Donate link: https://rtcamp.com/
Tags: Google login, sign in, sso, oauth, authentication, sign-in, single sign-on, log in
Requires at least: 5.0
Tested up to: 5.8.1
Requires at least: 5.5
Tested up to: 6.0.2
Requires PHP: 7.4
Stable tag: 1.3.0
Stable tag: 1.3.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -64,7 +64,6 @@ is OFF.
By default, when you enable user registration via constant `WP_GOOGLE_LOGIN_USER_REGISTRATION` or enable *Settings > WP Google Login > Enable Google Login Registration*, it will create a user for any Google login (including gmail.com users). If you are planning to use this plugin on a private, internal site, then you may like to restrict user registration to users under a single Google Suite organization. This configuration variable does that.

Add your domain name, without any schema prefix and `www,` as the value of `WP_GOOGLE_LOGIN_WHITELIST_DOMAINS` constant or in the settings `Settings > WP Google Login > Whitelisted Domains`. You can whitelist multiple domains. Please separate domains with commas. See the below example to know how to do it via constants:

```
define( 'WP_GOOGLE_LOGIN_WHITELIST_DOMAINS', 'example.com,sample.com' );
```
Expand All @@ -73,10 +72,7 @@ define( 'WP_GOOGLE_LOGIN_WHITELIST_DOMAINS', 'example.com,sample.com' );

### Hooks

Filter `wp_google_login_scopes`
This filter can be used to filter existing scope used in Google Sign in.
You can ask for additional permission while user logs in.
This filter will provide 1 parameter `scopes` in callback, which contains array of scopes.
For a list of all hooks please refer to [this documentation](https://github.com/rtCamp/login-with-google#hooks).

#### wp-config.php parameters list

Expand Down Expand Up @@ -141,6 +137,9 @@ Once you're ready to send a pull request, please run through the following check

== Changelog ==

= 1.3.1 =
* Maintenance release: Updated minimum requirements.

= 1.3.0 =
* Feature: Gutenberg block for Login button.
* Feature: Save user first name and last name on registration.
Expand Down Expand Up @@ -186,12 +185,5 @@ Once you're ready to send a pull request, please run through the following check

== Upgrade Notice ==

= 1.3.0 =
* Feature: Gutenberg block for Login button.
* Feature: Save user first name and last name on registration.
* Add: PHP 8.0 compatibility.
* Add: Added hook after user authentication.
* Add: Added hook after user is logged-in.
* Fix: set login cookie with shortcode display.
* Fix: Redirection back to login page issue.
* Updated npm packages and laravel-mix.
= 1.3.1 =
* Maintenance release: Updated minimum requirements.
Binary file modified wp-assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 34ad185

Please sign in to comment.