From 35635c9adc819f1774ed94165663fea476772433 Mon Sep 17 00:00:00 2001 From: German Lena Date: Fri, 4 Mar 2016 09:59:31 -0300 Subject: [PATCH 01/11] Change password #141 --- lib/WP_Auth0_Api_Client.php | 30 ++++++++++++ lib/WP_Auth0_EditProfile.php | 91 ++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/lib/WP_Auth0_Api_Client.php b/lib/WP_Auth0_Api_Client.php index 87558b2c..24ac3322 100644 --- a/lib/WP_Auth0_Api_Client.php +++ b/lib/WP_Auth0_Api_Client.php @@ -552,6 +552,36 @@ public static function update_user($domain, $app_token, $id, $payload) { return json_decode($response['body']); } + public static function change_password($domain, $payload) { + $endpoint = "https://$domain/dbconnections/change_password"; + + $headers = self::get_info_headers(); + + $headers['content-type'] = "application/json"; + + $response = wp_remote_post( $endpoint , array( + 'method' => 'POST', + 'headers' => $headers, + 'body' => json_encode($payload) + ) ); + + if ( $response instanceof WP_Error ) { + WP_Auth0_ErrorManager::insert_auth0_error( 'WP_Auth0_Api_Client::change_password', $response ); + error_log( $response->get_error_message() ); + return false; + } + + if ( $response['response']['code'] != 200 ) { + WP_Auth0_ErrorManager::insert_auth0_error( 'WP_Auth0_Api_Client::change_password', $response['body'] ); + error_log( $response['body'] ); + return false; + } + + if ( $response['response']['code'] >= 300 ) return false; + + return json_decode($response['body']); + } + public static function link_users($domain, $app_token, $main_user_id, $user_id, $provider, $connection_id = null) { $endpoint = "https://$domain/api/v2/users/$main_user_id/identities"; diff --git a/lib/WP_Auth0_EditProfile.php b/lib/WP_Auth0_EditProfile.php index 5e326b40..d4b8a990 100644 --- a/lib/WP_Auth0_EditProfile.php +++ b/lib/WP_Auth0_EditProfile.php @@ -15,11 +15,102 @@ public function init() { add_action( 'personal_options_update', array( $this, 'override_email_update' ), 1 ); + add_action( 'show_user_profile', array( $this, 'show_change_password' )); + add_action( 'personal_options_update', array( $this, 'update_change_password' ) ); + add_filter( 'user_profile_update_errors', array( $this, 'validate_new_password' ), 10, 3); + if ( $pagenow == 'profile.php' ) { add_action( 'admin_footer', array( $this, 'disable_email_field' ) ); } } + + public function validate_new_password($errors, $update, $user){ + $auth0_password = $_POST['auth0_password']; + $auth0_repeat_password = $_POST['auth0_repeat_password']; + + if (empty($auth0_password)) { + $errors->add( 'auth0_password', __('ERROR: The password can not be empty'), array( 'form-field' => 'auth0_password' ) ); + } + if ($auth0_password != $auth0_repeat_password) { + $errors->add( 'auth0_password', __('ERROR: The password does not match'), array( 'form-field' => 'auth0_password' ) ); + } + } + + + public function update_change_password() { + $user_profiles = $this->db_manager->get_current_user_profiles(); + + if (empty($user_profiles)) return; + + $auth0_password = $_POST['auth0_password']; + $auth0_repeat_password = $_POST['auth0_repeat_password']; + + if (empty($auth0_password) || $auth0_password == $auth0_repeat_password) { + $domain = $this->a0_options->get('domain'); + $client_id = $this->a0_options->get('client_id'); + + $user_profile = $user_profiles[0]; + $connection = null; + $email = null; + + foreach ($user_profile->identities as $identity) { + if ($identity->provider === 'auth0') { + $connection = $identity->connection; + $email = $identity->email; + } + } + + WP_Auth0_Api_Client::change_password($domain, array( + 'client_id' => $client_id, + 'email' => $user_profile->email, + 'password' => $auth0_password, + 'connection' => $connection + )); + } + } + + public function show_change_password() { + $user_profiles = $this->db_manager->get_current_user_profiles(); + + if (empty($user_profiles)) return; + + $user_profile = $user_profiles[0]; + $connection = null; + + foreach ($user_profile->identities as $identity) { + if ($identity->provider === 'auth0') { + $connection = $identity->connection; + } + } + + if ($connection === null) return; + ?> + + + + + + + + + + + +
+ + + +
+ + + +
+ db_manager->get_current_user_profiles(); From b8264904306922b0b4f45db7e834751dc539220a Mon Sep 17 00:00:00 2001 From: German Lena Date: Fri, 4 Mar 2016 10:05:39 -0300 Subject: [PATCH 02/11] word order for App token required scopes very confusing #140 --- lib/WP_Auth0_Api_Client.php | 2 ++ lib/admin/WP_Auth0_Admin_Basic.php | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/WP_Auth0_Api_Client.php b/lib/WP_Auth0_Api_Client.php index 24ac3322..7e64750c 100644 --- a/lib/WP_Auth0_Api_Client.php +++ b/lib/WP_Auth0_Api_Client.php @@ -649,6 +649,8 @@ public static function GetConsentScopestoShow() { foreach ($grouped as $resource => $actions) { $str = ""; + sort($actions); + for($a = 0; $a < count($actions); $a++) { if ($a > 0) { if ($a === count($actions) - 1) { diff --git a/lib/admin/WP_Auth0_Admin_Basic.php b/lib/admin/WP_Auth0_Admin_Basic.php index 8dc15b43..3e95e644 100644 --- a/lib/admin/WP_Auth0_Admin_Basic.php +++ b/lib/admin/WP_Auth0_Admin_Basic.php @@ -48,10 +48,9 @@ public function render_auth0_app_token() { - + $actions) { $a++;?> - - () . + Date: Fri, 4 Mar 2016 10:12:53 -0300 Subject: [PATCH 03/11] Register #142 --- assets/css/login.css | 1 + lib/WP_Auth0_Lock_Options.php | 15 ++++++++++++--- templates/auth0-login-form.php | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/assets/css/login.css b/assets/css/login.css index 841c87cc..7fdf80d6 100644 --- a/assets/css/login.css +++ b/assets/css/login.css @@ -64,6 +64,7 @@ body.a0-widget-open>* { fill: #bbb; } +#registerform, #loginform, #login #nav, .woocommerce-checkout .woocommerce-info, diff --git a/lib/WP_Auth0_Lock_Options.php b/lib/WP_Auth0_Lock_Options.php index 94743f32..89db8a7d 100644 --- a/lib/WP_Auth0_Lock_Options.php +++ b/lib/WP_Auth0_Lock_Options.php @@ -5,6 +5,8 @@ class WP_Auth0_Lock_Options { protected $wp_options; protected $extended_settings; + protected $signup_mode = false; + public function __construct($extended_settings = array()) { $this->wp_options = WP_Auth0_Options::Instance(); $this->extended_settings = $extended_settings; @@ -70,6 +72,10 @@ public function get_auth0_implicit_workflow() { return $this->_get_boolean( $this->wp_options->get('auth0_implicit_workflow') ); } + public function set_signup_mode($enabled) { + $this->signup_mode = $enabled; + } + public function is_registration_enabled() { return $this->wp_options->is_wp_registration_enabled(); } @@ -152,9 +158,12 @@ protected function build_settings( $settings ) { if ( $this->_is_valid( $settings, 'lock_connections' ) ) { $options_obj['connections'] = explode(",", $settings['lock_connections']); } - if ( isset( $settings['extra_conf'] ) && trim( $settings['extra_conf'] ) !== '' ) { - $extra_conf_arr = json_decode( $settings['extra_conf'], true ); - $options_obj = array_merge( $extra_conf_arr, $options_obj ); + if ( isset( $settings['extra_conf'] ) && trim( $settings['extra_conf'] ) !== '' ) { + $extra_conf_arr = json_decode( $settings['extra_conf'], true ); + $options_obj = array_merge( $extra_conf_arr, $options_obj ); + } + if ( $this->signup_mode ) { + $options_obj["mode"] = "signup"; } return $options_obj; } diff --git a/templates/auth0-login-form.php b/templates/auth0-login-form.php index 00a25170..49568c23 100644 --- a/templates/auth0-login-form.php +++ b/templates/auth0-login-form.php @@ -9,6 +9,10 @@ return; } +if (isset($_GET['action']) && $_GET['action'] == 'register') { + $lock_options->set_signup_mode(true); +} + $extra_css = trim(apply_filters( 'auth0_login_css', '')); $extra_css .= trim($lock_options->get_custom_css()); From 54361ba846f970ebb3a9634b837a316521ea5e09 Mon Sep 17 00:00:00 2001 From: German Lena Date: Mon, 7 Mar 2016 09:48:00 -0300 Subject: [PATCH 04/11] fix income rule --- lib/WP_Auth0_RulesLib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WP_Auth0_RulesLib.php b/lib/WP_Auth0_RulesLib.php index 62534e4f..3d89c66f 100644 --- a/lib/WP_Auth0_RulesLib.php +++ b/lib/WP_Auth0_RulesLib.php @@ -155,6 +155,7 @@ function (user, context, callback) { user.user_metadata = user.user_metadata || {}; var geoip = user.user_metadata.geoip || context.request.geoip; + var request = require('request'); if (!geoip || geoip.country_code !== 'US') return callback(null, user, context); @@ -164,7 +165,6 @@ function (user, context, callback) { setIncomeData(global.incomeData, user, geoip, context, callback); } - var request = require('request'); function retrieveIncomeData(user, geoip, context, callback) { request({ From 4e9d305423b0b03972d48efbaa3e8eec51ee6b46 Mon Sep 17 00:00:00 2001 From: German Lena Date: Mon, 7 Mar 2016 09:55:43 -0300 Subject: [PATCH 05/11] Typo #144 --- lib/admin/WP_Auth0_Admin_Features.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/admin/WP_Auth0_Admin_Features.php b/lib/admin/WP_Auth0_Admin_Features.php index 7e9ca385..dd853512 100644 --- a/lib/admin/WP_Auth0_Admin_Features.php +++ b/lib/admin/WP_Auth0_Admin_Features.php @@ -136,7 +136,7 @@ public function render_fullcontact() {
- + From 37088f19eb71ad66512504ad376bf4623a657039 Mon Sep 17 00:00:00 2001 From: German Lena Date: Mon, 7 Mar 2016 16:20:36 -0300 Subject: [PATCH 06/11] all rules will run only for the wp client, added site name to the rule name --- WP_Auth0.php | 2 +- lib/WP_Auth0_RulesLib.php | 21 ++++++++++++++++++++- lib/admin/WP_Auth0_Admin_Advanced.php | 2 +- lib/admin/WP_Auth0_Admin_Features.php | 15 ++++++++++----- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/WP_Auth0.php b/WP_Auth0.php index a8dfb798..1f3061f6 100644 --- a/WP_Auth0.php +++ b/WP_Auth0.php @@ -2,7 +2,7 @@ /** * Plugin Name: Auth0 for WordPress * Description: Implements the Auth0 Single Sign On solution into Wordpress - * Version: 2.0.3 + * Version: 2.0.4 * Author: Auth0 * Author URI: https://auth0.com */ diff --git a/lib/WP_Auth0_RulesLib.php b/lib/WP_Auth0_RulesLib.php index 3d89c66f..a8395bba 100644 --- a/lib/WP_Auth0_RulesLib.php +++ b/lib/WP_Auth0_RulesLib.php @@ -95,6 +95,13 @@ function (user, context, callback) { 'name' => 'Store-Geo-Location-Do-Not-Rename', 'script' => " function (user, context, callback) { + + var CLIENTS_WITH_MFA = ['REPLACE_WITH_YOUR_CLIENT_ID']; + // run only for the specified clients + if (CLIENTS_WITH_MFA.indexOf(context.clientID) === -1) { + return callback(null, user, context); + } + user.user_metadata = user.user_metadata || {}; user.user_metadata.geoip = context.request.geoip; auth0.users.updateUserMetadata(user.user_id, user.user_metadata) @@ -112,7 +119,13 @@ function (user, context, callback) { 'script' => " function (user, context, callback) { - var fullContactAPIKey = 'REPLACE_WITH_YOUR_CLIENT_ID'; + var CLIENTS_WITH_MFA = ['REPLACE_WITH_YOUR_CLIENT_ID']; + // run only for the specified clients + if (CLIENTS_WITH_MFA.indexOf(context.clientID) === -1) { + return callback(null, user, context); + } + + var fullContactAPIKey = 'REPLACE_WITH_YOUR_FULLCONTACT_API_KEY'; if(!user.email) { //the profile doesn't have email so we can't query fullcontact api. @@ -153,6 +166,12 @@ function (user, context, callback) { 'script' => " function (user, context, callback) { + var CLIENTS_WITH_MFA = ['REPLACE_WITH_YOUR_CLIENT_ID']; + // run only for the specified clients + if (CLIENTS_WITH_MFA.indexOf(context.clientID) === -1) { + return callback(null, user, context); + } + user.user_metadata = user.user_metadata || {}; var geoip = user.user_metadata.geoip || context.request.geoip; var request = require('request'); diff --git a/lib/admin/WP_Auth0_Admin_Advanced.php b/lib/admin/WP_Auth0_Admin_Advanced.php index 1263466f..3095395d 100644 --- a/lib/admin/WP_Auth0_Admin_Advanced.php +++ b/lib/admin/WP_Auth0_Admin_Advanced.php @@ -440,7 +440,7 @@ public function link_accounts_validation( $old_options, $input ) { $link_script = str_replace('REPLACE_WITH_YOUR_CLIENT_ID', $input['client_id'], $link_script); $link_script = str_replace('REPLACE_WITH_YOUR_DOMAIN', $input['domain'], $link_script); $link_script = str_replace('REPLACE_WITH_YOUR_API_TOKEN', $input['auth0_app_token'], $link_script); - return $this->rule_validation($old_options, $input, 'link_auth0_users', WP_Auth0_RulesLib::$link_accounts['name'], $link_script); + return $this->rule_validation($old_options, $input, 'link_auth0_users', WP_Auth0_RulesLib::$link_accounts['name'] . '-' . get_bloginfo('name'), $link_script); } public function loginredirection_validation( $old_options, $input ) { diff --git a/lib/admin/WP_Auth0_Admin_Features.php b/lib/admin/WP_Auth0_Admin_Features.php index dd853512..c1f06076 100644 --- a/lib/admin/WP_Auth0_Admin_Features.php +++ b/lib/admin/WP_Auth0_Admin_Features.php @@ -204,23 +204,28 @@ public function security_validation( $old_options, $input ) { public function fullcontact_validation( $old_options, $input ) { $fullcontact_script = WP_Auth0_RulesLib::$fullcontact['script']; - $fullcontact_script = str_replace('REPLACE_WITH_YOUR_CLIENT_ID', $input['fullcontact_apikey'], $fullcontact_script); - return $this->rule_validation($old_options, $input, 'fullcontact', WP_Auth0_RulesLib::$fullcontact['name'], $fullcontact_script); + $fullcontact_script = str_replace('REPLACE_WITH_YOUR_CLIENT_ID', $input['client_id'], $fullcontact_script); + $fullcontact_script = str_replace('REPLACE_WITH_YOUR_FULLCONTACT_API_KEY', $input['fullcontact_apikey'], $fullcontact_script); + return $this->rule_validation($old_options, $input, 'fullcontact', WP_Auth0_RulesLib::$fullcontact['name']. '-' . get_bloginfo('name'), $fullcontact_script); } public function mfa_validation( $old_options, $input ) { $mfa_script = WP_Auth0_RulesLib::$google_MFA['script']; $mfa_script = str_replace('REPLACE_WITH_YOUR_CLIENT_ID', $input['client_id'], $mfa_script); - return $this->rule_validation($old_options, $input, 'mfa', WP_Auth0_RulesLib::$google_MFA['name'], $mfa_script); + return $this->rule_validation($old_options, $input, 'mfa', WP_Auth0_RulesLib::$google_MFA['name'] . '-' . get_bloginfo('name'), $mfa_script); } public function georule_validation( $old_options, $input ) { - return $this->rule_validation($old_options, $input, 'geo_rule', WP_Auth0_RulesLib::$geo['name'], WP_Auth0_RulesLib::$geo['script']); + $geo_script = WP_Auth0_RulesLib::$geo['script']; + $geo_script = str_replace('REPLACE_WITH_YOUR_CLIENT_ID', $input['client_id'], $geo_script); + return $this->rule_validation($old_options, $input, 'geo_rule', WP_Auth0_RulesLib::$geo['name'] . '-' . get_bloginfo('name'), $geo_script); } public function incomerule_validation( $old_options, $input ) { - return $this->rule_validation($old_options, $input, 'income_rule', WP_Auth0_RulesLib::$income['name'], WP_Auth0_RulesLib::$income['script']); + $income_script = WP_Auth0_RulesLib::$income['script']; + $income_script = str_replace('REPLACE_WITH_YOUR_CLIENT_ID', $input['client_id'], $income_script); + return $this->rule_validation($old_options, $input, 'income_rule', WP_Auth0_RulesLib::$income['name'] . '-' . get_bloginfo('name'), $income_script); } } From dfd0b74a6d36bd9868bb6b192c76b403ec5d0156 Mon Sep 17 00:00:00 2001 From: German Lena Date: Tue, 8 Mar 2016 09:07:50 -0300 Subject: [PATCH 07/11] fix settings in multisite --- lib/WP_Auth0_Options_Generic.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/WP_Auth0_Options_Generic.php b/lib/WP_Auth0_Options_Generic.php index af35eb35..2eda9784 100644 --- a/lib/WP_Auth0_Options_Generic.php +++ b/lib/WP_Auth0_Options_Generic.php @@ -10,7 +10,7 @@ public function get_options_name() { public function get_options(){ if(empty($this->_opt)){ - $options = get_site_option( $this->options_name, array()); + $options = get_option( $this->options_name, array()); if(!is_array($options)) $options = $this->defaults(); @@ -35,12 +35,12 @@ public function set( $key, $value ){ $options[$key] = $value; $this->_opt = $options; - update_site_option( $this->options_name, $options ); + update_option( $this->options_name, $options ); } public function save() { $options = $this->get_options(); - update_site_option( $this->options_name, $options ); + update_option( $this->options_name, $options ); } protected function defaults(){ From 9974acaed4a326af7e47fcf1752224d94a76c7d5 Mon Sep 17 00:00:00 2001 From: German Lena Date: Tue, 8 Mar 2016 09:08:10 -0300 Subject: [PATCH 08/11] fix redirect to for sso --- lib/WP_Auth0_Lock_Options.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/WP_Auth0_Lock_Options.php b/lib/WP_Auth0_Lock_Options.php index 89db8a7d..999622e0 100644 --- a/lib/WP_Auth0_Lock_Options.php +++ b/lib/WP_Auth0_Lock_Options.php @@ -181,8 +181,17 @@ public function get_sso_options() { $options["callbackOnLocationHash"] = false; $options["callbackURL"] = $this->get_code_callback_url(); } + + $redirect_to = null; + + if (isset($_GET['redirect_to'])){ + $redirect_to = $_GET['redirect_to']; + } else { + $redirect_to = home_url($_SERVER["REQUEST_URI"]); + } + unset($options["authParams"]); - $options["state"] = $this->get_state_obj(home_url($_SERVER["REQUEST_URI"])); + $options["state"] = $this->get_state_obj($redirect_to); return $options; From d1af7be79c3ccdfceece78d37748bc250823e85c Mon Sep 17 00:00:00 2001 From: German Lena Date: Tue, 8 Mar 2016 10:48:13 -0300 Subject: [PATCH 09/11] added button to reset user MFA --- lib/WP_Auth0_Api_Client.php | 29 ++++++++++++++ lib/WP_Auth0_EditProfile.php | 63 +++++++++++++++++++++++++++++- lib/admin/WP_Auth0_Admin_Basic.php | 1 + 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/lib/WP_Auth0_Api_Client.php b/lib/WP_Auth0_Api_Client.php index 7e64750c..1e332f93 100644 --- a/lib/WP_Auth0_Api_Client.php +++ b/lib/WP_Auth0_Api_Client.php @@ -521,6 +521,35 @@ public static function delete_connection($domain, $app_token, $id) { return json_decode($response['body']); } + public static function delete_user_mfa($domain, $app_token, $user_id, $provider) { + + $endpoint = "https://$domain/api/v2/users/$user_id/multifactor/$provider"; + + $headers = self::get_info_headers(); + + $headers['Authorization'] = "Bearer $app_token"; + $headers['content-type'] = "application/json"; + + $response = wp_remote_post( $endpoint , array( + 'method' => 'DELETE', + 'headers' => $headers + ) ); + + if ( $response instanceof WP_Error ) { + WP_Auth0_ErrorManager::insert_auth0_error( 'WP_Auth0_Api_Client::delete_user_mfa', $response ); + error_log( $response->get_error_message() ); + return false; + } + + if ( $response['response']['code'] != 204 ) { + WP_Auth0_ErrorManager::insert_auth0_error( 'WP_Auth0_Api_Client::delete_user_mfa', $response['body'] ); + error_log( $response['body'] ); + return false; + } + + return json_decode($response['body']); + } + public static function update_user($domain, $app_token, $id, $payload) { $endpoint = "https://$domain/api/v2/users/$id"; diff --git a/lib/WP_Auth0_EditProfile.php b/lib/WP_Auth0_EditProfile.php index d4b8a990..45a8c3b7 100644 --- a/lib/WP_Auth0_EditProfile.php +++ b/lib/WP_Auth0_EditProfile.php @@ -15,16 +15,20 @@ public function init() { add_action( 'personal_options_update', array( $this, 'override_email_update' ), 1 ); + add_action( 'edit_user_profile', array( $this, 'show_delete_mfa' )); + add_action( 'show_user_profile', array( $this, 'show_delete_mfa' )); + + add_action( 'wp_ajax_auth0_delete_mfa', array( $this, 'delete_mfa' ) ); + add_action( 'show_user_profile', array( $this, 'show_change_password' )); add_action( 'personal_options_update', array( $this, 'update_change_password' ) ); add_filter( 'user_profile_update_errors', array( $this, 'validate_new_password' ), 10, 3); - if ( $pagenow == 'profile.php' ) { + if ( $pagenow == 'profile.php' || $pagenow == 'user-edit.php' ) { add_action( 'admin_footer', array( $this, 'disable_email_field' ) ); } } - public function validate_new_password($errors, $update, $user){ $auth0_password = $_POST['auth0_password']; $auth0_repeat_password = $_POST['auth0_repeat_password']; @@ -70,6 +74,61 @@ public function update_change_password() { } } + public function delete_mfa() { + if ( ! is_admin() ) return; + + $user_id = $_POST["user_id"]; + + $users = $this->db_manager->get_auth0_users(array($user_id)); + if (empty($users)) return; + + $user_id = $users[0]->auth0_id; + + $provider = 'google-authenticator'; + $domain = $this->a0_options->get('domain'); + $app_token = $this->a0_options->get('auth0_app_token'); + + WP_Auth0_Api_Client::delete_user_mfa($domain, $app_token, $user_id, $provider); + } + + public function show_delete_mfa() { + if ( ! is_admin() ) return; + if ( ! $this->a0_options->get('mfa') ) return; + + ?> + + + + + +
+ + + +
+ + + db_manager->get_current_user_profiles(); diff --git a/lib/admin/WP_Auth0_Admin_Basic.php b/lib/admin/WP_Auth0_Admin_Basic.php index 3e95e644..4e686fde 100644 --- a/lib/admin/WP_Auth0_Admin_Basic.php +++ b/lib/admin/WP_Auth0_Admin_Basic.php @@ -165,6 +165,7 @@ public function basic_validation( $old_options, $input ) { } public function basicdata_validation( $old_options, $input ) { + $error = ''; $completeBasicData = true; if ( empty( $input['domain'] ) ) { From 74d2e8cd8c1d8c626461c0911205aba794ce3fe2 Mon Sep 17 00:00:00 2001 From: German Lena Date: Tue, 8 Mar 2016 13:15:42 -0300 Subject: [PATCH 10/11] fix registration enabled for multisite --- lib/WP_Auth0_EditProfile.php | 6 +++++- lib/WP_Auth0_Options.php | 5 ++++- lib/admin/WP_Auth0_Admin_Basic.php | 2 +- lib/admin/WP_Auth0_Admin_Features.php | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/WP_Auth0_EditProfile.php b/lib/WP_Auth0_EditProfile.php index 45a8c3b7..c68f85b2 100644 --- a/lib/WP_Auth0_EditProfile.php +++ b/lib/WP_Auth0_EditProfile.php @@ -61,7 +61,11 @@ public function update_change_password() { foreach ($user_profile->identities as $identity) { if ($identity->provider === 'auth0') { $connection = $identity->connection; - $email = $identity->email; + if (isset($identity->email)) { + $email = $identity->email; + } else { + $email = $user_profile->email; + } } } diff --git a/lib/WP_Auth0_Options.php b/lib/WP_Auth0_Options.php index 527d7287..0602d58d 100755 --- a/lib/WP_Auth0_Options.php +++ b/lib/WP_Auth0_Options.php @@ -13,7 +13,10 @@ public static function Instance() { protected $options_name = 'wp_auth0_settings'; public function is_wp_registration_enabled() - { + { + if (is_multisite()) { + return users_can_register_signup_filter(); + } return (get_site_option('users_can_register', 0) == 1); } diff --git a/lib/admin/WP_Auth0_Admin_Basic.php b/lib/admin/WP_Auth0_Admin_Basic.php index 4e686fde..fd446432 100644 --- a/lib/admin/WP_Auth0_Admin_Basic.php +++ b/lib/admin/WP_Auth0_Admin_Basic.php @@ -94,7 +94,7 @@ public function render_allow_signup() { } public function render_allow_signup_regular_multisite() { - $allow_signup = $this->options->is_wp_registration_enabled(); + $allow_signup = $this->options->is_wp_registration_enabled(); ?> diff --git a/lib/admin/WP_Auth0_Admin_Features.php b/lib/admin/WP_Auth0_Admin_Features.php index c1f06076..eb3d2f25 100644 --- a/lib/admin/WP_Auth0_Admin_Features.php +++ b/lib/admin/WP_Auth0_Admin_Features.php @@ -88,6 +88,7 @@ public function render_mfa() { . . +
Date: Tue, 8 Mar 2016 13:17:09 -0300 Subject: [PATCH 11/11] bump version --- WP_Auth0.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WP_Auth0.php b/WP_Auth0.php index 1f3061f6..502e7abb 100644 --- a/WP_Auth0.php +++ b/WP_Auth0.php @@ -12,7 +12,7 @@ define( 'WPA0_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); define( 'WPA0_LANG', 'wp-auth0' ); define( 'AUTH0_DB_VERSION', 4 ); -define( 'WPA0_VERSION', '2.0.3' ); +define( 'WPA0_VERSION', '2.1.0' ); /** * Main plugin class