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 { toast } from "sonner";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
const addServerDomain = z.object({
|
const addServerDomain = z
|
||||||
domain: z.string().min(1, { message: "URL is required" }),
|
.object({
|
||||||
letsEncryptEmail: z.string().min(1, "Email is required").email(),
|
domain: z.string().min(1, { message: "URL is required" }),
|
||||||
certificateType: z.enum(["letsencrypt", "none"]),
|
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>;
|
type AddServerDomain = z.infer<typeof addServerDomain>;
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,9 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
const admin = await updateAdmin(ctx.user.authId, {
|
const admin = await updateAdmin(ctx.user.authId, {
|
||||||
host: input.host,
|
host: input.host,
|
||||||
letsEncryptEmail: input.letsEncryptEmail,
|
...(input.letsEncryptEmail && {
|
||||||
|
letsEncryptEmail: input.letsEncryptEmail,
|
||||||
|
}),
|
||||||
certificateType: input.certificateType,
|
certificateType: input.certificateType,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -186,7 +188,10 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateServerTraefik(admin, input.host);
|
updateServerTraefik(admin, input.host);
|
||||||
updateLetsEncryptEmail(admin.letsEncryptEmail);
|
if (input.letsEncryptEmail) {
|
||||||
|
updateLetsEncryptEmail(input.letsEncryptEmail);
|
||||||
|
}
|
||||||
|
|
||||||
return admin;
|
return admin;
|
||||||
}),
|
}),
|
||||||
cleanSSHPrivateKey: adminProcedure.mutation(async ({ ctx }) => {
|
cleanSSHPrivateKey: adminProcedure.mutation(async ({ ctx }) => {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const createSchema = createInsertSchema(admins, {
|
|||||||
sshPrivateKey: z.string().optional(),
|
sshPrivateKey: z.string().optional(),
|
||||||
certificateType: z.enum(["letsencrypt", "none"]).default("none"),
|
certificateType: z.enum(["letsencrypt", "none"]).default("none"),
|
||||||
serverIp: z.string().optional(),
|
serverIp: z.string().optional(),
|
||||||
|
letsEncryptEmail: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiSaveSSHKey = createSchema
|
export const apiSaveSSHKey = createSchema
|
||||||
@@ -55,11 +56,14 @@ export const apiSaveSSHKey = createSchema
|
|||||||
|
|
||||||
export const apiAssignDomain = createSchema
|
export const apiAssignDomain = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
letsEncryptEmail: true,
|
|
||||||
host: true,
|
host: true,
|
||||||
certificateType: true,
|
certificateType: true,
|
||||||
|
letsEncryptEmail: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required()
|
||||||
|
.partial({
|
||||||
|
letsEncryptEmail: true,
|
||||||
|
});
|
||||||
|
|
||||||
export const apiUpdateDockerCleanup = createSchema
|
export const apiUpdateDockerCleanup = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
Reference in New Issue
Block a user