Allow admins to assign the creator role

This commit is contained in:
Dan
2026-06-29 14:10:54 +00:00
parent c9aed9f283
commit ed30020b6c
+2 -4
View File
@@ -39,7 +39,7 @@ export async function POST(req: Request, ctx: { params: Promise<{ id: string }>
}
case "role": {
const r = body.value as Role;
if (!["admin", "learner"].includes(r))
if (!["admin", "learner", "creator"].includes(r))
return NextResponse.json({ error: "Invalid role." }, { status: 400 });
// Guard: don't let an admin demote the last remaining admin (themselves included).
if (target.role === "admin" && r !== "admin") {
@@ -49,6 +49,4 @@ export async function POST(req: Request, ctx: { params: Promise<{ id: string }>
return NextResponse.json({ ok: true });
}
default:
return NextResponse.json({ error: "Unknown action." }, { status: 400 });
}
}
return NextResponse.json({ error: "Unknown action." }, { status: 400