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

When selecting existing license in Activation modal #747

Open
LC43 opened this issue Oct 9, 2024 · 0 comments
Open

When selecting existing license in Activation modal #747

LC43 opened this issue Oct 9, 2024 · 0 comments

Comments

@LC43
Copy link

LC43 commented Oct 9, 2024

modal:
Screenshot 2024-10-09 at 13-52-42 Plugins ‹ interactive globes  — WordPress

When activating a premium license, in the modal, selecting the existing account license, the API returns an error

Uncaught SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

Request:

action | "fs_activate_license_xxxxx"
security | "xxxxxxxxxxxx"
module_id | "xxxxx"
license_key | ""

due to licenseID being set to a number

                licenseID = $availableLicenseKey.data( 'id' );`

then it checks for empty, but will pass since licenseKey.length is true

                if ( 0 === licenseID.length && 0 === licenseKey.length ) {

later, it will check again, and since if fails by checking the lenght of a number ( undefined ), it will try data.license_key = licenseKey, but licenseKey is empty, so the API will get empty values.

                if ( licenseID.length > 0 ) {
                    data.license_id = licenseID;
                } else {
                    data.license_key = licenseKey;
                }

https://github.com/Freemius/wordpress-sdk/blob/cc31279d088909135b6b2d8b4f2696312f5731fc/templates/forms/license-activation.php#L572C62-L572C66

Solution

Either convert it to string, or just check if licenseID !== ''

Versions: (*)

2.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant