-
Notifications
You must be signed in to change notification settings - Fork 79
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
[privacy] [activation] If there is no user during activation shows a … #705
Changes from all commits
4ae2490
85e2548
3819d2a
8dfebe2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13763,7 +13763,10 @@ function _activate_license_ajax_action() { | |
fs_request_get( 'module_id', null, 'post' ), | ||
fs_request_get( 'user_id', null ), | ||
fs_request_get_bool( 'is_extensions_tracking_allowed', null ), | ||
fs_request_get_bool( 'is_diagnostic_tracking_allowed', null ) | ||
fs_request_get_bool( 'is_diagnostic_tracking_allowed', null ), | ||
fs_request_get( 'user_firstname', null ), | ||
fs_request_get( 'user_lastname', null ), | ||
fs_request_get( 'user_email', null ) | ||
); | ||
|
||
if ( | ||
|
@@ -14026,7 +14029,10 @@ private function activate_license( | |
$plugin_id = null, | ||
$license_owner_id = null, | ||
$is_extensions_tracking_allowed = null, | ||
$is_diagnostic_tracking_allowed = null | ||
$is_diagnostic_tracking_allowed = null, | ||
$user_firstname = null, | ||
$user_lastname = null, | ||
$user_email = null | ||
) { | ||
$this->_logger->entrance(); | ||
|
||
|
@@ -14052,7 +14058,8 @@ private function activate_license( | |
) ); | ||
|
||
$error = false; | ||
$next_page = false; | ||
$error_code = false; | ||
$next_page = false; | ||
|
||
$has_valid_blog_id = is_numeric( $blog_id ); | ||
|
||
|
@@ -14186,9 +14193,9 @@ private function activate_license( | |
$fs->update_connectivity_info( $is_connected ); | ||
} else { | ||
$next_page = $fs->opt_in( | ||
false, | ||
false, | ||
false, | ||
$user_email, | ||
$user_firstname, | ||
$user_lastname, | ||
$license_key, | ||
false, | ||
false, | ||
|
@@ -14199,6 +14206,7 @@ private function activate_license( | |
|
||
if ( isset( $next_page->error ) ) { | ||
$error = $next_page->error; | ||
$error_code = $next_page->code; | ||
} else { | ||
if ( $is_network_activation_or_migration ) { | ||
/** | ||
|
@@ -14267,6 +14275,7 @@ private function activate_license( | |
|
||
if ( false !== $error ) { | ||
$result['error'] = $fs->apply_filters( 'opt_in_error_message', $error ); | ||
$result['error_code'] = $error_code; | ||
} else { | ||
if ( $fs->is_addon() || $fs->has_addons() ) { | ||
/** | ||
|
@@ -17202,8 +17211,6 @@ function is_beta() { | |
function get_opt_in_params( $override_with = array(), $network_level_or_blog_id = null ) { | ||
$this->_logger->entrance(); | ||
|
||
$current_user = self::_get_current_wp_user(); | ||
|
||
$activation_action = $this->get_unique_affix() . '_activate_new'; | ||
$return_url = $this->is_anonymous() ? | ||
// If skipped already, then return to the account page. | ||
|
@@ -17214,9 +17221,6 @@ function get_opt_in_params( $override_with = array(), $network_level_or_blog_id | |
$versions = $this->get_versions(); | ||
|
||
$params = array_merge( $versions, array( | ||
'user_firstname' => $current_user->user_firstname, | ||
'user_lastname' => $current_user->user_lastname, | ||
'user_email' => $current_user->user_email, | ||
'plugin_slug' => $this->_slug, | ||
'plugin_id' => $this->get_id(), | ||
'plugin_public_key' => $this->get_public_key(), | ||
|
@@ -17329,7 +17333,7 @@ function opt_in( | |
) { | ||
$this->_logger->entrance(); | ||
|
||
if ( false === $email ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this Instead of removing it, I think it should be something like |
||
if ( false === $email && empty( $license_key ) ) { | ||
$current_user = self::_get_current_wp_user(); | ||
$email = $current_user->user_email; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,7 +324,34 @@ class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous() | |
) | ||
); | ||
?> | ||
<div id="fs_marketing_optin"> | ||
<!-- BEGIN EXPLICIT DATA FIELDS --> | ||
<div id="fs_personal_data" class="fs_gdpr_consent"> | ||
<!-- | ||
The fields below are used to explicitly collect missing information in cases where it is not possible | ||
to assign an existing user to the license being activated. This was done to avoid sending private data | ||
in any case. | ||
--> | ||
<span class="fs-message"><?php fs_echo_inline( "Please enter at least a valid email address to activate your license:", | ||
'email-is-requested' ) ?></span> | ||
<div class="fs-fields-container"> | ||
<div class="fs-input-container"> | ||
<label for="fs_first_name" class="screen-reader-text">First name</label> | ||
<input type="text" id="fs_first_name" name="first_name" placeholder="First name" | ||
class="fs-input"> | ||
</div> | ||
<div class="fs-input-container"> | ||
<label for="fs_last_name" class="screen-reader-text">Last name</label> | ||
<input type="text" id="fs_last_name" name="last_name" placeholder="Last name" class="fs-input"> | ||
</div> | ||
<div class="fs-input-container"> | ||
<label for="fs_user_email" class="screen-reader-text">Email (required)</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DanieleAlessandra For the label and the input's placeholder, instead of |
||
<input type="email" id="fs_user_email" name="user_email" placeholder="Email (required)" | ||
class="fs-input" required> | ||
</div> | ||
</div> | ||
</div> | ||
<!-- END EXPLICIT DATA FIELDS --> | ||
<div id="fs_marketing_optin" class="fs_gdpr_consent"> | ||
<span class="fs-message"><?php fs_echo_inline( "Please let us know if you'd like us to contact you for security & feature updates, educational content, and occasional offers:", 'contact-for-updates' ) ?></span> | ||
<div class="fs-input-container"> | ||
<label> | ||
|
@@ -525,6 +552,11 @@ class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'S | |
$( document.body ).addClass( 'fs-loading' ); | ||
}; | ||
|
||
$( '#fs_personal_data input' ).on( 'focus', function () { | ||
$( '#fs_personal_data' ).removeClass( 'error' ); | ||
resetLoadingMode(); | ||
} ); | ||
|
||
$('.fs-actions .button').on('click', function () { | ||
setLoadingMode(); | ||
|
||
|
@@ -697,6 +729,19 @@ function updatePrimaryCtaText( actionType ) { | |
var ajaxOptin = ( requireLicenseKey || isNetworkActive ); | ||
|
||
$form.on('submit', function () { | ||
const personal_data = {}; | ||
if ( $personalData.is( ':visible' ) ) { | ||
const email_field = document.querySelector( '#fs_user_email' ); | ||
if ( !email_field.checkValidity() ) { | ||
$personalData.addClass( 'error' ).show(); | ||
resetLoadingMode(); | ||
return false; | ||
} else { | ||
personal_data.user_firstname = $( '#fs_first_name' ).val(); | ||
personal_data.user_lastname = $( '#fs_last_name' ).val(); | ||
personal_data.user_email = $( email_field ).val(); | ||
} | ||
} | ||
var $extensionsPermission = $( '#fs_permission_extensions .fs-switch' ), | ||
isExtensionsTrackingAllowed = ( $extensionsPermission.length > 0 ) ? | ||
$extensionsPermission.hasClass( 'fs-on' ) : | ||
|
@@ -743,7 +788,8 @@ function updatePrimaryCtaText( actionType ) { | |
action : action, | ||
security : security, | ||
license_key: licenseKey, | ||
module_id : '<?php echo $fs->get_id() ?>' | ||
module_id : '<?php echo $fs->get_id() ?>', | ||
...personal_data | ||
}; | ||
|
||
if ( | ||
|
@@ -827,15 +873,17 @@ function updatePrimaryCtaText( actionType ) { | |
method : 'POST', | ||
data : data, | ||
success: function (result) { | ||
var resultObj = $.parseJSON(result); | ||
if (resultObj.success) { | ||
// Redirect to the "Account" page and sync the license. | ||
window.location.href = resultObj.next_page; | ||
} else { | ||
resetLoadingMode(); | ||
|
||
// Show error. | ||
$('.fs-content').prepend('<div class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</div>'); | ||
var resultObj = $.parseJSON(result); | ||
if (resultObj.success) { | ||
// Redirect to the "Account" page and sync the license. | ||
window.location.href = resultObj.next_page; | ||
} else { | ||
resetLoadingMode(); | ||
// Show error. | ||
$('.fs-content').prepend('<div class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</div>'); | ||
if (resultObj.error_code === 'empty_email') { | ||
$('#fs_personal_data').show(); | ||
} | ||
} | ||
}, | ||
error: function () { | ||
|
@@ -960,6 +1008,7 @@ function updatePrimaryCtaText( actionType ) { | |
//-------------------------------------------------------------------------------- | ||
var isMarketingAllowedByLicense = {}, | ||
$marketingOptin = $('#fs_marketing_optin'), | ||
$personalData = $('#fs_personal_data') | ||
previousLicenseKey = null; | ||
|
||
if (requireLicenseKey) { | ||
|
@@ -1034,11 +1083,12 @@ function updatePrimaryCtaText( actionType ) { | |
|
||
$marketingOptin.find( 'input' ).click(function() { | ||
$marketingOptin.removeClass( 'error' ); | ||
$personalData.removeClass( 'error' ); | ||
}); | ||
} | ||
|
||
//endregion | ||
})(jQuery); | ||
</script> | ||
<?php | ||
fs_require_once_template( 'api-connectivity-message-js.php' ); | ||
fs_require_once_template( 'api-connectivity-message-js.php' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the
$current_user
variable is no longer used, we can remove the declaration above.