admin
This commit is contained in:
44
scripts/create-test-user.ts
Normal file
44
scripts/create-test-user.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log("🔧 ساخت کاربر تست...\n");
|
||||
|
||||
const email = "test@test.com";
|
||||
const password = "123456";
|
||||
const hashedPassword = await bcrypt.hash(password, 10);
|
||||
|
||||
// حذف کاربر قبلی اگر وجود دارد
|
||||
await prisma.user.deleteMany({
|
||||
where: { email },
|
||||
});
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email,
|
||||
password: hashedPassword,
|
||||
name: "کاربر تست",
|
||||
role: "USER",
|
||||
},
|
||||
});
|
||||
|
||||
console.log("✅ کاربر تست ساخته شد:");
|
||||
console.log(` ایمیل: ${email}`);
|
||||
console.log(` رمز عبور: ${password}`);
|
||||
console.log(` ID: ${user.id}`);
|
||||
console.log(` نقش: ${user.role}`);
|
||||
console.log("\n🔐 برای ورود از این اطلاعات استفاده کنید:");
|
||||
console.log(` Email: ${email}`);
|
||||
console.log(` Password: ${password}`);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error("❌ خطا:", e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user