This commit is contained in:
2026-04-07 10:38:28 +03:30
parent aa9ed69dd2
commit 8bcd1c2951
99 changed files with 3357 additions and 178 deletions

70
scripts/check-users.ts Normal file
View File

@@ -0,0 +1,70 @@
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
async function main() {
console.log("🔍 بررسی کاربران...\n");
const users = await prisma.user.findMany({
select: {
id: true,
email: true,
name: true,
role: true,
createdAt: true,
team: {
select: {
id: true,
name: true,
},
},
},
});
console.log(`تعداد کاربران: ${users.length}\n`);
users.forEach((user, index) => {
console.log(`${index + 1}. ${user.email}`);
console.log(` ID: ${user.id}`);
console.log(` نام: ${user.name || "ندارد"}`);
console.log(` نقش: ${user.role}`);
console.log(` تیم: ${user.team ? user.team.name : "ندارد"}`);
console.log(` تاریخ ثبت‌نام: ${user.createdAt.toISOString()}`);
console.log("");
});
// بررسی Session ها
const sessions = await prisma.session.findMany({
select: {
id: true,
userId: true,
expires: true,
user: {
select: {
email: true,
},
},
},
});
console.log(`\n📋 تعداد Session های فعال: ${sessions.length}\n`);
sessions.forEach((session, index) => {
const isExpired = session.expires < new Date();
console.log(`${index + 1}. User: ${session.user.email}`);
console.log(` Session ID: ${session.id}`);
console.log(` User ID: ${session.userId}`);
console.log(` وضعیت: ${isExpired ? "منقضی شده ❌" : "فعال ✓"}`);
console.log(` انقضا: ${session.expires.toISOString()}`);
console.log("");
});
}
main()
.catch((e) => {
console.error("❌ خطا:", e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});

View 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 = "admin@admin.com";
const password = "admin123";
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: "ADMIN",
},
});
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();
});

View 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();
});