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

Added support for WooCommerce + updated info headers #63

Merged
merged 5 commits into from
May 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ All the details about the parameters on the lock wiki (https://github.com/auth0/

## FAQs

### Is this plugin compatible with WooCommerce?

Yes, this plugin will override the default WooCommerce login forms with the Lock widget.

### What should I do if I end up with two accounts for the same user?

Under some situations, you may end up with a user with two accounts. **WordPress** allows you to do merge users. You just delete one of the accounts and then attribute its contents to the user you want to merge with. Go to Users, select the account you want to delete, and in the confirmation dialog select another user to transfer the content.
Expand Down
19 changes: 17 additions & 2 deletions WP_Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Wordpress Auth0 Integration
* Description: Implements the Auth0 Single Sign On solution into Wordpress
* Version: 1.2.1
* Version: 1.2.2
* Author: Auth0
* Author URI: https://auth0.com
*/
Expand All @@ -12,7 +12,7 @@
define('WPA0_PLUGIN_URL', trailingslashit(plugin_dir_url(__FILE__) ));
define('WPA0_LANG', 'wp-auth0');
define('AUTH0_DB_VERSION', 2);
define('WPA0_VERSION', '1.2.1');
define('WPA0_VERSION', '1.2.2');

class WP_Auth0 {
public static function init(){
Expand Down Expand Up @@ -69,6 +69,21 @@ public static function init(){
WP_Auth0_Configure_JWTAUTH::init();

add_action('plugins_loaded', array( __CLASS__, 'checkJWTAuth' ));
add_filter( 'woocommerce_checkout_login_message', array(__CLASS__, 'override_woocommerce_checkout_login_form') );
add_filter( 'woocommerce_before_customer_login_form', array(__CLASS__, 'override_woocommerce_login_form') );
}

public static function override_woocommerce_checkout_login_form( $html ){
self::override_woocommerce_login_form($html);

if (isset($_GET['wle'])) {
echo "<style>.woocommerce-checkout .woocommerce-info{display:block;}</style>";
}
}

public static function override_woocommerce_login_form( $html ){
self::render_auth0_login_css();
echo self::render_form('');
}

public static function isJWTAuthEnabled() {
Expand Down
22 changes: 16 additions & 6 deletions assets/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
body.a0-widget-open>* {
display: inherit;
}
#loginform{
display: none;
}
#login #nav {
display: none;
}
#a0-widget .a0-panel{
margin: auto;
}
Expand All @@ -31,4 +25,20 @@ body.a0-widget-open>* {
}
.auth0-login{
margin-bottom: 20px;
}

#loginform,
#login #nav,
.woocommerce-checkout .woocommerce-info,
.woocommerce-account .woocommerce h2,
.woocommerce-account .woocommerce form.login {
display: none;
}

.woocommerce-checkout .woocommerce-info ~ .woocommerce-info {
display: block;
}

.woocommerce-account #extra-options {
padding:0;
}
8 changes: 6 additions & 2 deletions lib/WP_Auth0_Api_Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ protected static function get_info_headers() {
global $wp_version;

return array(
'User-Agent' => 'PHP/' . phpversion() . ' (WordPress:' . $wp_version . ')',
'Auth0-Client' => base64_encode(json_encode(array(
'name' => 'wp-auth0',
'version' => WPA0_VERSION
'version' => WPA0_VERSION,

'environment' => array(
'PHP' => phpversion(),
'WordPress' => $wp_version,
)
)))
);
}
Expand Down
4 changes: 3 additions & 1 deletion templates/back-to-auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
?>

<style>
#loginform{
#loginform,
.woocommerce-account .woocommerce h2,
.woocommerce-account .woocommerce form.login {
display: block !important;
}
</style>
Expand Down
1 change: 1 addition & 0 deletions templates/login-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function renderAuth0Form($canShowLegacyLogin = true, $specialSettings = array())
require_once ('auth0-login-form.php');
}else{
add_action('login_footer', array('WP_Auth0', 'render_back_to_auth0'));
add_action('woocommerce_after_customer_login_form', array('WP_Auth0', 'render_back_to_auth0'));
}
}

Expand Down