Fix admin user id from URL params, raise landing logo/buttons
This commit is contained in:
@@ -3,12 +3,17 @@ import { prisma } from "@/lib/prisma";
|
||||
import { requireAdmin } from "@/lib/session";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
export async function PATCH(req: NextRequest) {
|
||||
export async function PATCH(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const admin = await requireAdmin();
|
||||
if (!admin) return NextResponse.json({ error: "Admin requis" }, { status: 403 });
|
||||
|
||||
const { id, ...data } = await req.json();
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const id = params?.id || body.id;
|
||||
if (!id) return NextResponse.json({ error: "id requis" }, { status: 400 });
|
||||
const { id: _bodyId, ...data } = body;
|
||||
|
||||
const allowed = [
|
||||
"name", "email", "isMuayThai", "isYoga", "role", "phone", "avatar", "password"
|
||||
@@ -59,11 +64,15 @@ export async function PATCH(req: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(req: NextRequest) {
|
||||
export async function DELETE(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const admin = await requireAdmin();
|
||||
if (!admin) return NextResponse.json({ error: "Admin requis" }, { status: 403 });
|
||||
|
||||
const { id } = await req.json();
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const id = params?.id || body.id;
|
||||
if (!id) return NextResponse.json({ error: "id requis" }, { status: 400 });
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user