fix/postgres template autogenerate password when value is empty

This commit is contained in:
biersoeckli
2024-12-22 16:49:08 +00:00
parent a809a4384b
commit 039d28b612
3 changed files with 8 additions and 1 deletions
+4
View File
@@ -6,6 +6,7 @@ import { getAuthUserSession, saveFormAction, simpleAction } from "@/server/utils
import { z } from "zod";
import appTemplateService from "@/server/services/app-template.service";
import { AppTemplateModel, appTemplateZodModel } from "@/shared/model/app-template.model";
import { ServiceException } from "@/shared/model/service.exception.model";
const createAppSchema = z.object({
appName: z.string().min(1)
@@ -27,6 +28,9 @@ export const createApp = async (appName: string, projectId: string, appId?: stri
export const createAppFromTemplate = async(prevState: any, inputData: AppTemplateModel, projectId: string) =>
saveFormAction(inputData, appTemplateZodModel, async (validatedData) => {
await getAuthUserSession();
if (validatedData.templates.some(x => x.inputSettings.some(y => !y.randomGeneratedIfEmpty && !y.value))) {
throw new ServiceException('Please fill out all required fields.');
}
await appTemplateService.createAppFromTemplate(projectId, validatedData);
return new SuccessActionResult(undefined, "App created successfully.");
});
@@ -52,6 +52,9 @@ export default function CreateTemplateAppSetupDialog({
description: `Click deploy to start the ${appLabel}.`,
});
setIsOpen(false);
if (dialogClosed) {
dialogClosed();
}
}
FormUtils.mapValidationErrorsToForm<typeof appTemplateZodModel>(state, form);
}, [state]);
@@ -31,7 +31,7 @@ export const postgreAppTemplate: AppTemplateModel = {
label: "Database Password",
value: "",
isEnvVar: true,
randomGeneratedIfEmpty: false,
randomGeneratedIfEmpty: true,
},
],
appModel: {