to do calendar view
This commit is contained in:
20
app/api/users/current-user/route.ts
Normal file
20
app/api/users/current-user/route.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "../../auth/[...nextauth]/route";
|
||||
import { NextResponse } from "next/server";
|
||||
import { queries } from "@/lib/queries";
|
||||
|
||||
export async function GET() {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
if (!session?.user.id) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const user = await queries.fetchCurrentUser(session.user.id)
|
||||
|
||||
if (!user) {
|
||||
return NextResponse.json({ error: 'User not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
return NextResponse.json(user);
|
||||
}
|
||||
Reference in New Issue
Block a user