feat: add admin authentication

This commit is contained in:
2026-09-18 16:50:35 +08:00
parent b89853bc94
commit bb5ccb1359
9 changed files with 85 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import { PrismaClient } from "@prisma/client";
import { hash } from "bcryptjs";
const prisma = new PrismaClient();
@@ -54,6 +55,15 @@ async function main(): Promise<void> {
create: { brandId: brand.id, name, isPreset: true },
});
}
await prisma.adminUser.upsert({
where: { username: "admin" },
update: {},
create: {
username: "admin",
passwordHash: await hash(process.env.SEED_ADMIN_PASSWORD ?? "change-me-now-123", 12),
displayName: "品牌管理员",
},
});
}
main().finally(() => prisma.$disconnect());