2026-06-15 09:28:22 +02:00
|
|
|
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
|
import { requireAuth } from "@/lib/auth";
|
|
|
|
|
|
|
|
|
|
export async function GET(req: NextRequest) {
|
|
|
|
|
const jwtPayload = await requireAuth(req);
|
|
|
|
|
if (!jwtPayload) {
|
|
|
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const user = await prisma.user.findUnique({
|
|
|
|
|
where: { id: jwtPayload.userId },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
return NextResponse.json({ error: "User not found" }, { status: 404 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NextResponse.json({
|
|
|
|
|
user: {
|
|
|
|
|
id: user.id,
|
|
|
|
|
email: user.email,
|
|
|
|
|
name: user.name,
|
|
|
|
|
isPremium: user.isPremium,
|
|
|
|
|
isPro: user.isPro,
|
|
|
|
|
flhBalance: user.flhBalance,
|
2026-06-28 23:02:48 +02:00
|
|
|
flhPurchased: (user as any).flhPurchased ?? 0,
|
2026-06-15 09:28:22 +02:00
|
|
|
dailyMsgCount: user.dailyMsgCount,
|
|
|
|
|
experienceLevel: user.experienceLevel,
|
|
|
|
|
madhab: user.madhab,
|
|
|
|
|
coachPersona: user.coachPersona,
|
|
|
|
|
preferredName: user.preferredName,
|
|
|
|
|
coachingGoals: user.coachingGoals,
|
|
|
|
|
trialEndsAt: user.trialEndsAt,
|
|
|
|
|
createdAt: user.createdAt,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|