- FiveM License Management Panel - Next.js/React
- Features
- API Endpoints
- Getting Started
- Setting Up Super Admin
- API Usage Examples
- License
- Contribution
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.
- 🔐 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.
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. |
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.
- Clone this repository:
git clone https://github.com/caglarop/fivem-license-managment-panel.git
- Navigate to the directory:
cd fivem-license-managment-panel
- Install the dependencies:
or if you prefer using Yarn:
npm install
yarn install
- Copy the
.env.example
file and rename it to.env
. Fill it with the necessary environment variables as per the provided settings. - Run the following commands to migrate the database:
or if you prefer using Yarn:
npx prisma generate npx prisma migrate dev
yarn prisma generate yarn prisma migrate dev
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.
To set yourself as a Super Admin, you can use Prisma Studio. Here are the steps:
-
Start Prisma Studio:
npx prisma studio
or if you prefer using Yarn:
yarn prisma studio
-
Prisma Studio will open in your default web browser. Navigate to the
User
model. -
Find your user entry in the list and click on it to edit.
-
Set the
isSuperAdmin
field totrue
. -
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.
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.
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.
This project is licensed under the MIT License. See the LICENSE file for details.
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.