Allow admins to assign the creator role
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user