Skip to content

caglarop/fivem-license-managment-panel

Repository files navigation

Table of Contents

🎮 FiveM License Management Panel - Next.js/React

This robust panel simplifies the management of script licenses for FiveM script vendors, enabling customers to tailor their licenses and configure IP addresses for FiveM servers.

🌟 Features

  • 🔐 Discord Login: Streamlined authentication through Discord.
  • 🔧 API Endpoints: Comprehensive API endpoints for various functionalities.
  • 🔄 License Update: Enable customers to update their IP addresses with 24h lock.
  • 🔒 Secure and Structured: Built with Typescript for robustness and clarity.

📡 API Endpoints

Method Endpoint Description
GET /api/license/[id] Retrieve license details and settings for a specific ID.
GET /api/license/list List all available licenses.
POST /api/license/update/ip/[id] Update the IP address associated with a license.
GET /api/session Check the authenticity of a user session.
GET /api/user/[id] Retrieve user information, including ID, email, super admin status, name, and image.
GET /api/license-check/[productName]/[licenseKey] Verify the validity of a license key for a specific product.

Getting Started 🚀

Before you begin, ensure that you have met the following requirements:

  • You have installed the latest version of Node.js and npm.
  • You have installed Git on your machine.

Installation 🛠️

  1. Clone this repository:
    git clone https://github.com/caglarop/fivem-license-managment-panel.git
  2. Navigate to the directory:
    cd fivem-license-managment-panel
  3. Install the dependencies:
    npm install
    or if you prefer using Yarn:
    yarn install

Configuration ⚙️

  1. Copy the .env.example file and rename it to .env. Fill it with the necessary environment variables as per the provided settings.
  2. Run the following commands to migrate the database:
    npx prisma generate
    npx prisma migrate dev
    or if you prefer using Yarn:
    yarn prisma generate
    yarn prisma migrate dev

Starting 🎬

To start the panel, run the following command:

npm run dev

or if you prefer using Yarn:

yarn dev

Then, access the panel at http://localhost:3000.

Setting Up Super Admin 🛡️

To set yourself as a Super Admin, you can use Prisma Studio. Here are the steps:

  1. Start Prisma Studio:

    npx prisma studio

    or if you prefer using Yarn:

    yarn prisma studio
  2. Prisma Studio will open in your default web browser. Navigate to the User model.

  3. Find your user entry in the list and click on it to edit.

  4. Set the isSuperAdmin field to true.

  5. Click Save to apply the changes.

Now, you have Super Admin privileges in the application.

Please note: Be careful when assigning Super Admin privileges, as users with this role have extensive control over the application.

API Usage Examples

Lua Usage (FiveM)

To verify the validity of a license key in a FiveM script, here's an example using a callback function:

function checkLicense(licenseKey, callback)
    local productName = GetCurrentResourceName()
    local url = "http://yourdomain.com/api/license-check/" .. productName .. "/" .. licenseKey

    PerformHttpRequest(url, function(statusCode, responseText, headers)
        if statusCode == 200 then
            local responseData = json.decode(responseText)
            if responseData and responseData.allowed then
                if responseData.allowed == true then
                    callback(true)
                    return
                end
            end
        end

        callback(false)
    end, 'GET', '')
end

-- Example usage
checkLicense(function(isAllowed)
    if isAllowed then
        print("License is valid!")
        -- Continue your script logic here
    else
        print("License is not valid!")
        StopResource(GetCurrentResourceName())
    end
end)

Ensure you replace "your_license_key_here" with actual values relevant to your use case.

JavaScript Usage

For general web applications or server-side scripts, here's how you can use the API in JavaScript:

function checkLicense(licenseKey, callback) {
    const productName = GetCurrentResourceName();
    const url = `http://yourdomain.com/api/license-check/${productName}/${licenseKey}`;

    fetch(url)
        .then(response => response.json())
        .then(data => {
            if (data.allowed) {
                callback(true);
            } else {
                callback(false);
            }
        })
        .catch(error => {
            callback(false);
        });
}

// Example usage
checkLicense("your_license_key_here", function(isAllowed) {
    if (isAllowed) {
        console.log("License is valid!");
        // Continue your script logic here
    } else {
        console.log("License is not valid.");
        StopResource(GetCurrentResourceName());
    }
});

Ensure you replace "your_license_key_here" with actual values relevant to your use case.

License 📜

This project is licensed under the MIT License. See the LICENSE file for details.

Contribution 🤝

Contributions are welcome! If you have a feature request, bug report, or proposal for code improvement, please feel free to open an issue or submit a pull request.

Releases

No releases published

Packages

No packages published

Languages