mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-23 04:18:45 +00:00
refactor: implement safe URL validation for whitelabeling settings in both client and server schemas
This commit is contained in:
@@ -30,15 +30,21 @@ import { Textarea } from "@/components/ui/textarea";
|
|||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { WhitelabelingPreview } from "./whitelabeling-preview";
|
import { WhitelabelingPreview } from "./whitelabeling-preview";
|
||||||
|
|
||||||
|
const safeUrlField = z
|
||||||
|
.string()
|
||||||
|
.refine((val) => val === "" || /^https?:\/\//i.test(val), {
|
||||||
|
message: "Only http:// and https:// URLs are allowed",
|
||||||
|
});
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
appName: z.string(),
|
appName: z.string(),
|
||||||
appDescription: z.string(),
|
appDescription: z.string(),
|
||||||
logoUrl: z.string(),
|
logoUrl: safeUrlField,
|
||||||
faviconUrl: z.string(),
|
faviconUrl: safeUrlField,
|
||||||
customCss: z.string(),
|
customCss: z.string(),
|
||||||
loginLogoUrl: z.string(),
|
loginLogoUrl: safeUrlField,
|
||||||
supportUrl: z.string(),
|
supportUrl: safeUrlField,
|
||||||
docsUrl: z.string(),
|
docsUrl: safeUrlField,
|
||||||
errorPageTitle: z.string(),
|
errorPageTitle: z.string(),
|
||||||
errorPageDescription: z.string(),
|
errorPageDescription: z.string(),
|
||||||
metaTitle: z.string(),
|
metaTitle: z.string(),
|
||||||
|
|||||||
@@ -187,16 +187,23 @@ export const apiUpdateDockerCleanup = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Whitelabeling validation schemas
|
// Whitelabeling validation schemas
|
||||||
|
const safeUrl = z
|
||||||
|
.string()
|
||||||
|
.refine((url) => /^https?:\/\//i.test(url), {
|
||||||
|
message: "Only http:// and https:// URLs are allowed",
|
||||||
|
})
|
||||||
|
.nullable();
|
||||||
|
|
||||||
export const whitelabelingConfigSchema = z.object({
|
export const whitelabelingConfigSchema = z.object({
|
||||||
appName: z.string().nullable(),
|
appName: z.string().nullable(),
|
||||||
appDescription: z.string().nullable(),
|
appDescription: z.string().nullable(),
|
||||||
logoUrl: z.string().nullable(),
|
logoUrl: safeUrl,
|
||||||
faviconUrl: z.string().nullable(),
|
faviconUrl: safeUrl,
|
||||||
primaryColor: z.string().nullable(),
|
primaryColor: z.string().nullable(),
|
||||||
customCss: z.string().nullable(),
|
customCss: z.string().nullable(),
|
||||||
loginLogoUrl: z.string().nullable(),
|
loginLogoUrl: safeUrl,
|
||||||
supportUrl: z.string().nullable(),
|
supportUrl: safeUrl,
|
||||||
docsUrl: z.string().nullable(),
|
docsUrl: safeUrl,
|
||||||
errorPageTitle: z.string().nullable(),
|
errorPageTitle: z.string().nullable(),
|
||||||
errorPageDescription: z.string().nullable(),
|
errorPageDescription: z.string().nullable(),
|
||||||
metaTitle: z.string().nullable(),
|
metaTitle: z.string().nullable(),
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { sendEmailNotification } from "../utils/notifications/utils";
|
||||||
sendDiscordNotification,
|
|
||||||
sendEmailNotification,
|
|
||||||
} from "../utils/notifications/utils";
|
|
||||||
export const sendEmail = async ({
|
export const sendEmail = async ({
|
||||||
email,
|
email,
|
||||||
subject,
|
subject,
|
||||||
@@ -26,26 +23,3 @@ export const sendEmail = async ({
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendDiscordNotificationWelcome = async (email: string) => {
|
|
||||||
await sendDiscordNotification(
|
|
||||||
{
|
|
||||||
webhookUrl: process.env.DISCORD_WEBHOOK_URL || "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "New User Registered",
|
|
||||||
color: 0x00ff00,
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
name: "Email",
|
|
||||||
value: email,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
timestamp: new Date(),
|
|
||||||
footer: {
|
|
||||||
text: "Dokploy User Registration Notification",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user