equipes keycloak flow

This commit is contained in:
alma 2025-05-03 15:50:20 +02:00
parent d40811a1e8
commit ca3bdb0f07

View File

@ -5,7 +5,7 @@ import { getKeycloakAdminClient } from "@/lib/keycloak";
export async function GET(
request: Request,
context: { params: { userId: string } }
{ params }: { params: { userId?: string } }
) {
try {
const session = await getServerSession(authOptions);
@ -13,8 +13,9 @@ export async function GET(
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
// Use the userId from context instead of trying to destructure it
const userId = context.params.userId.toString();
// Just get the primitive value directly
const rawUserId = params?.userId;
const userId = typeof rawUserId === 'string' ? rawUserId : '';
if (!userId) {
return NextResponse.json({ error: "User ID is required" }, { status: 400 });
@ -75,7 +76,7 @@ export async function GET(
export async function PUT(
request: Request,
context: { params: { userId: string } }
{ params }: { params: { userId?: string } }
) {
try {
const session = await getServerSession(authOptions);
@ -83,8 +84,9 @@ export async function PUT(
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
// Use the userId from context instead of trying to destructure it
const userId = context.params.userId.toString();
// Just get the primitive value directly
const rawUserId = params?.userId;
const userId = typeof rawUserId === 'string' ? rawUserId : '';
if (!userId) {
return NextResponse.json({ error: "User ID is required" }, { status: 400 });