From 5f51011ce17317d6b2ed8f36b73082fe80043117 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 26 Sep 2022 13:36:54 +0200 Subject: [PATCH] fix: empty preview value --- apps/api/src/routes/api/v1/applications/handlers.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index 0a2414a12..70c593728 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -15,7 +15,6 @@ import { checkContainer, formatLabelsOnDocker, isContainerExited, removeContaine import type { FastifyRequest } from 'fastify'; import type { GetImages, CancelDeployment, CheckDNS, CheckRepository, DeleteApplication, DeleteSecret, DeleteStorage, GetApplicationLogs, GetBuildIdLogs, SaveApplication, SaveApplicationSettings, SaveApplicationSource, SaveDeployKey, SaveDestination, SaveSecret, SaveStorage, DeployApplication, CheckDomain, StopPreviewApplication, RestartPreviewApplication, GetBuilds } from './types'; import { OnlyId } from '../../../../types'; -import path from 'node:path'; function filterObject(obj, callback) { return Object.fromEntries(Object.entries(obj). @@ -326,7 +325,7 @@ export async function saveApplicationSettings(request: FastifyRequest) { export async function updatePreviewSecret(request: FastifyRequest, reply: FastifyReply) { try { const { id } = request.params - const { name, value } = request.body + let { name, value } = request.body + if (value) { + value = encrypt(value.trim()) + } else { + value = '' + } await prisma.secret.updateMany({ where: { applicationId: id, name, isPRMRSecret: true }, - data: { value: encrypt(value.trim()) } + data: { value } }); return reply.code(201).send() } catch ({ status, message }) {