diff --git a/README.md b/README.md index f5f1b5d6..89df5212 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,23 @@ If the filter returns null, it will lookup by email as stated in the [How doe it } ``` +### Customize autologin connection + +This filter will allow to programatically set which connection the plugin should use when autologin is enabled. + +``` + add_filter( 'auth0_get_auto_login_connection', 'auth0_get_auto_login_connection', 1, 1 ); + + function auth0_get_auto_login_connection($connection) { + + if ( /* check some condition */ ) { + return 'twitter'; + } + + return $connection; + } +``` + ## API authentication The last version of the plugin provides the ability integrate with **wp-jwt-auth** plugin to authenticate api calls via a HTTP Authorization Header. diff --git a/WP_Auth0.php b/WP_Auth0.php index 71e4ce5b..c51a0f6f 100644 --- a/WP_Auth0.php +++ b/WP_Auth0.php @@ -2,7 +2,7 @@ /** * Plugin Name: PLUGIN_NAME * Description: PLUGIN_DESCRIPTION - * Version: 3.2.18 + * Version: 3.2.19 * Author: Auth0 * Author URI: https://auth0.com */ @@ -11,7 +11,7 @@ define( 'WPA0_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); define( 'WPA0_LANG', 'wp-auth0' ); define( 'AUTH0_DB_VERSION', 13 ); -define( 'WPA0_VERSION', '3.2.18' ); +define( 'WPA0_VERSION', '3.2.19' ); /** * Main plugin class @@ -449,4 +449,4 @@ function get_auth0_curatedBlogName() { } $a0_plugin = new WP_Auth0(); -$a0_plugin->init(); +$a0_plugin->init(); \ No newline at end of file diff --git a/lib/WP_Auth0_LoginManager.php b/lib/WP_Auth0_LoginManager.php index 1d2a15de..f626e97d 100644 --- a/lib/WP_Auth0_LoginManager.php +++ b/lib/WP_Auth0_LoginManager.php @@ -129,13 +129,15 @@ public function login_auto() { } $state = base64_encode( json_encode( $stateObj ) ); + $connection = apply_filters( 'auth0_get_auto_login_connection', $this->a0_options->get( 'auto_login_method' ) ); + // Create the link to log in. $login_url = "https://". $this->a0_options->get( 'domain' ) . "/authorize?response_type=code&scope=openid%20profile". "&client_id=".$this->a0_options->get( 'client_id' ) . "&redirect_uri=".home_url( '/index.php?auth0=1' ) . "&state=".urlencode( $state ). - "&connection=".$this->a0_options->get( 'auto_login_method' ). + "&connection=". trim($connection) . "&auth0Client=" . WP_Auth0_Api_Client::get_info_headers(); wp_redirect( $login_url );