瀏覽代碼

fix: hash API keys with bcrypt in seed (was plaintext)

clawPi4Bot 2 月之前
父節點
當前提交
e54c51d1e5
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      apps/api-server/src/db/seed.ts

+ 2 - 1
apps/api-server/src/db/seed.ts

@@ -65,7 +65,8 @@ async function seed() {
 
   for (const d of deviceNames) {
     const deviceId = d.serial  // ID = serial for easy POC testing
-    const apiKeyHash = `dev-api-key-${d.serial.toLowerCase()}`
+    const apiKeyPlain = `dev-api-key-${d.serial.toLowerCase()}`
+    const apiKeyHash = await bcrypt.hash(apiKeyPlain, 10)
     await db.insert(devices).values({
       id: deviceId,
       orgId,