From 928d53e532f293951923590a58f1ba849b03548a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 6 Jul 2022 11:49:07 +0200 Subject: [PATCH] fix: Seeding --- apps/api/prisma/seed.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/api/prisma/seed.js b/apps/api/prisma/seed.js index 011359682..78a625e17 100644 --- a/apps/api/prisma/seed.js +++ b/apps/api/prisma/seed.js @@ -23,7 +23,8 @@ async function main() { await prisma.setting.create({ data: { isRegistrationEnabled: true, - isTraefikUsed: true, + proxyPassword: encrypt(generatePassword()), + proxyUser: cuid() } }); } else { @@ -72,4 +73,16 @@ main() }) .finally(async () => { await prisma.$disconnect(); - }); \ No newline at end of file + }); + +const encrypt = (text) => { + if (text) { + const iv = crypto.randomBytes(16); + const cipher = crypto.createCipheriv(algorithm, process.env['COOLIFY_SECRET_KEY'], iv); + const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); + return JSON.stringify({ + iv: iv.toString('hex'), + content: encrypted.toString('hex') + }); + } +}; \ No newline at end of file