mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix(traefik): allow to save domain without letsencrypt email when the cert is none #542
This commit is contained in:
@@ -29,11 +29,22 @@ import { useForm } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
import { z } from "zod";
|
||||
|
||||
const addServerDomain = z.object({
|
||||
domain: z.string().min(1, { message: "URL is required" }),
|
||||
letsEncryptEmail: z.string().min(1, "Email is required").email(),
|
||||
certificateType: z.enum(["letsencrypt", "none"]),
|
||||
});
|
||||
const addServerDomain = z
|
||||
.object({
|
||||
domain: z.string().min(1, { message: "URL is required" }),
|
||||
letsEncryptEmail: z.string(),
|
||||
certificateType: z.enum(["letsencrypt", "none"]),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
if (data.certificateType === "letsencrypt" && !data.letsEncryptEmail) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
"LetsEncrypt email is required when certificate type is letsencrypt",
|
||||
path: ["letsEncryptEmail"],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
type AddServerDomain = z.infer<typeof addServerDomain>;
|
||||
|
||||
|
||||
@@ -174,7 +174,9 @@ export const settingsRouter = createTRPCRouter({
|
||||
}
|
||||
const admin = await updateAdmin(ctx.user.authId, {
|
||||
host: input.host,
|
||||
letsEncryptEmail: input.letsEncryptEmail,
|
||||
...(input.letsEncryptEmail && {
|
||||
letsEncryptEmail: input.letsEncryptEmail,
|
||||
}),
|
||||
certificateType: input.certificateType,
|
||||
});
|
||||
|
||||
@@ -186,7 +188,10 @@ export const settingsRouter = createTRPCRouter({
|
||||
}
|
||||
|
||||
updateServerTraefik(admin, input.host);
|
||||
updateLetsEncryptEmail(admin.letsEncryptEmail);
|
||||
if (input.letsEncryptEmail) {
|
||||
updateLetsEncryptEmail(input.letsEncryptEmail);
|
||||
}
|
||||
|
||||
return admin;
|
||||
}),
|
||||
cleanSSHPrivateKey: adminProcedure.mutation(async ({ ctx }) => {
|
||||
|
||||
@@ -45,6 +45,7 @@ const createSchema = createInsertSchema(admins, {
|
||||
sshPrivateKey: z.string().optional(),
|
||||
certificateType: z.enum(["letsencrypt", "none"]).default("none"),
|
||||
serverIp: z.string().optional(),
|
||||
letsEncryptEmail: z.string().optional(),
|
||||
});
|
||||
|
||||
export const apiSaveSSHKey = createSchema
|
||||
@@ -55,11 +56,14 @@ export const apiSaveSSHKey = createSchema
|
||||
|
||||
export const apiAssignDomain = createSchema
|
||||
.pick({
|
||||
letsEncryptEmail: true,
|
||||
host: true,
|
||||
certificateType: true,
|
||||
letsEncryptEmail: true,
|
||||
})
|
||||
.required();
|
||||
.required()
|
||||
.partial({
|
||||
letsEncryptEmail: true,
|
||||
});
|
||||
|
||||
export const apiUpdateDockerCleanup = createSchema
|
||||
.pick({
|
||||
|
||||
Reference in New Issue
Block a user