Files
football-next/scripts/check-users.ts

71 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { PrismaClient } from "../lib/generated/prisma";
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();
});