feat: add admin authentication
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user