Skip to content

Managing license key activation with no recognizable user #766

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion assets/scss/admin/_gdpr-consent.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.fs_on_missing_user
{
display: none;
}

#fs_marketing_optin
{
display: none;
Expand All @@ -6,6 +11,14 @@
padding: 10px;
line-height: 1.5em;

#fs_missing_user_notice
{
color: $fs-logo-magenta-color;
padding-bottom: 10px;
margin-bottom: 10px;
border-bottom: 1px solid #ccc;
}

.fs-message
{
display: block;
Expand Down Expand Up @@ -78,4 +91,4 @@
margin-right: 20px;
}
}
}
}
9 changes: 7 additions & 2 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -25809,11 +25809,16 @@ private function fetch_user_marketing_flag_status_by_plugins( $user_email, $lice
if (
!is_object($decoded) ||
!isset($decoded->success) ||
true !== $decoded->success ||
!isset( $decoded->data ) ||
!is_array( $decoded->data )
(!is_array( $decoded->data ) && !is_object( $decoded->data ))
// $decoded->data should be Array in case of success and stdObject in case of failure.
) {
return false;
} else if (
isset($decoded->data->error->code) &&
'no_user_for_license' === $decoded->data->error->code
) {
self::shoot_ajax_failure('no_user_for_license');
}

$result = array_merge( $result, $decoded->data );
Expand Down
2 changes: 1 addition & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.10.0.2';
$this_sdk_version = '2.10.0.3';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down
24 changes: 21 additions & 3 deletions templates/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous()
);
?>
<div id="fs_marketing_optin">
<div id="fs_missing_user_notice" class="fs_on_missing_user">
<span class="fs-message">
<?php fs_echo_inline("A user has not yet been associated with the license, which is necessary to prevent unauthorized activation. To assign the license to your user, you agree to share your WP user's full name and email address.",
'missing-user-notice') ?>
</span>
</div>
<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>
Expand Down Expand Up @@ -369,7 +375,8 @@ class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'S
<input type="hidden" name="is_extensions_tracking_allowed" value="1">
<input type="hidden" name="is_diagnostic_tracking_allowed" value="1">
<button class="button button-primary" tabindex="1"
type="submit"><?php echo esc_html( $button_label ) ?></button>
type="submit">
<?php echo esc_html( $button_label ) ?></button>
</form>
<?php else : ?>
<form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
Expand All @@ -382,7 +389,9 @@ class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'S
<button class="button button-primary" tabindex="1"
type="submit"<?php if ( $require_license_key ) {
echo ' disabled="disabled"';
} ?>><?php echo esc_html( $button_label ) ?></button>
} ?>>
<span class="fs_on_missing_user"><?php echo esc_html( 'Agree and ' ) ?></span>
<?php echo esc_html( $button_label ) ?></button>
</form>
<?php endif ?>
<?php if ( $require_license_key ) : ?>
Expand Down Expand Up @@ -982,12 +991,19 @@ function updatePrimaryCtaText( actionType ) {
$primaryCta.focus();
}
},
hideMissingUserElements = function () {
$('.fs_on_missing_user').hide();
},
showMissingUserElements = function () {
$('.fs_on_missing_user').show();
},
/**
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*/
fetchIsMarketingAllowedFlagAndToggleOptin = function () {
var licenseKey = $licenseKeyInput.val();
hideMissingUserElements();

if (licenseKey.length < 32) {
$marketingOptin.hide();
Expand Down Expand Up @@ -1024,6 +1040,8 @@ function updatePrimaryCtaText( actionType ) {

// Cache result.
isMarketingAllowedByLicense[licenseKey] = result.is_marketing_allowed;
} else if ("no_user_for_license" === result.error) {
showMissingUserElements();
}

afterMarketingFlagLoaded();
Expand All @@ -1040,4 +1058,4 @@ function updatePrimaryCtaText( actionType ) {
})(jQuery);
</script>
<?php
fs_require_once_template( 'api-connectivity-message-js.php' );
fs_require_once_template( 'api-connectivity-message-js.php' );
Loading