Compare commits
2 Commits
curator-he
...
7879b63498
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7879b63498 | ||
|
|
91ebaa0e44 |
@@ -81,11 +81,12 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
let assignments: { genreIds: Set<number>; specialIds: Set<number> } | null = null;
|
let assignments: { genreIds: Set<number>; specialIds: Set<number> } | null = null;
|
||||||
if (context.role === 'curator') {
|
if (context.role === 'curator') {
|
||||||
assignments = await getCuratorAssignments(context.curator.id);
|
const curatorAssignments = await getCuratorAssignments(context.curator.id);
|
||||||
|
assignments = curatorAssignments;
|
||||||
|
|
||||||
// Validate genre/special toggles are within curator's assignments
|
// Validate genre/special toggles are within curator's assignments
|
||||||
if (hasGenreToggle) {
|
if (hasGenreToggle) {
|
||||||
const invalidGenre = genreToggleIds.some((id: number) => !assignments.genreIds.has(id));
|
const invalidGenre = genreToggleIds.some((id: number) => !curatorAssignments.genreIds.has(id));
|
||||||
if (invalidGenre) {
|
if (invalidGenre) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Curators may only toggle their own genres' },
|
{ error: 'Curators may only toggle their own genres' },
|
||||||
@@ -95,7 +96,7 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasSpecialToggle) {
|
if (hasSpecialToggle) {
|
||||||
const invalidSpecial = specialToggleIds.some((id: number) => !assignments.specialIds.has(id));
|
const invalidSpecial = specialToggleIds.some((id: number) => !curatorAssignments.specialIds.has(id));
|
||||||
if (invalidSpecial) {
|
if (invalidSpecial) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Curators may only toggle their own specials' },
|
{ error: 'Curators may only toggle their own specials' },
|
||||||
|
|||||||
Reference in New Issue
Block a user