Neah version calendar fix

This commit is contained in:
alma 2025-04-16 21:03:39 +02:00
parent ca4d86f238
commit cb481a4f3f
3 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { authOptions } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
/**

View File

@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { authOptions } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
/**

View File

@ -11,7 +11,7 @@ import { prisma } from "@/lib/prisma";
*
* The function performs the following steps:
* 1. Retrieves the server session using `getServerSession`.
* 2. Checks if the user is authenticated by verifying the presence of `session.user.id`.
* 2. Checks if the user is authenticated by verifying the presence of `session.user.username`.
* - If not authenticated, returns a 401 response with an error message.
* 3. Attempts to fetch the calendars associated with the authenticated user from the database.
* - If successful, returns the calendars in a JSON response.
@ -20,14 +20,14 @@ import { prisma } from "@/lib/prisma";
export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
if (!session?.user?.id) {
if (!session?.user?.username) {
return NextResponse.json({ error: "Non authentifié" }, { status: 401 });
}
try {
const calendars = await prisma.calendar.findMany({
where: {
userId: session.user.id,
userId: session.user.username,
},
include: {
events: {