mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-18 12:25:25 +02:00
- Added support for whitelabeling, allowing customization of app name, logo, favicon, tagline, and custom CSS. - Introduced new database columns to store whitelabel settings. - Updated various components to utilize whitelabel settings, including the logo and favicon in the UI. - Enhanced the onboarding layout and sidebar to reflect whitelabel configurations. - Integrated whitelabel settings into the application head for dynamic title and favicon updates.
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { getPublicIpWithFallback } from "@dokploy/server/wss/utils";
|
|
import { and, eq, isNotNull } from "drizzle-orm";
|
|
import { scheduleJob } from "node-schedule";
|
|
import { db } from "../../db/index";
|
|
import { user as userSchema } from "../../db/schema/user";
|
|
|
|
export const LICENSE_KEY_URL =
|
|
// process.env.NODE_ENV === "development"
|
|
// ? "http://localhost:4002"
|
|
"https://licenses-api.dokploy.com";
|
|
|
|
export const initEnterpriseBackupCronJobs = async () => {
|
|
scheduleJob("enterprise-check", "0 0 */3 * *", async () => {
|
|
const users = await db.query.user.findMany({
|
|
where: and(
|
|
isNotNull(userSchema.licenseKey),
|
|
isNotNull(userSchema.enableEnterpriseFeatures),
|
|
eq(userSchema.isValidEnterpriseLicense, true),
|
|
),
|
|
});
|
|
for (const user of users) {
|
|
if (user.isValidEnterpriseLicense) {
|
|
console.log(
|
|
"Validating license key....",
|
|
user.firstName,
|
|
user.lastName,
|
|
);
|
|
try {
|
|
const isValid = await validateLicenseKey(user.licenseKey || "");
|
|
if (!isValid) {
|
|
throw new Error("License key is invalid");
|
|
}
|
|
} catch (error) {
|
|
await db
|
|
.update(userSchema)
|
|
.set({ isValidEnterpriseLicense: false })
|
|
.where(eq(userSchema.id, user.id));
|
|
}
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
export const validateLicenseKey = async (licenseKey: string) => {
|
|
try {
|
|
const ip = await getPublicIpWithFallback();
|
|
const result = await fetch(`${LICENSE_KEY_URL}/licenses/validate`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({ licenseKey, ip }),
|
|
});
|
|
|
|
if (!result.ok) {
|
|
const errorData = await result.json().catch(() => ({}));
|
|
throw new Error(errorData.message || "Failed to validate license key");
|
|
}
|
|
|
|
const data = await result.json();
|
|
return data.valid;
|
|
} catch (error) {
|
|
console.error(
|
|
error instanceof Error ? error.message : "Failed to validate license key",
|
|
);
|
|
throw error;
|
|
}
|
|
};
|