Skip to content

Commit

Permalink
Fix: Safer way of filtering out private lesson plans from resource view
Browse files Browse the repository at this point in the history
  • Loading branch information
aberonni committed Jan 24, 2024
1 parent 94d6f9e commit 3182523
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/server/api/routers/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export const resourceRouter = createTRPCRouter({
},
},
lessonPlanItems: {
where: {
section: {
lessonPlan: {
private: false,
},
},
},
select: {
section: {
select: {
lessonPlan: {
select: {
id: true,
title: true,
private: true,
},
},
},
Expand Down Expand Up @@ -178,8 +184,6 @@ export const resourceRouter = createTRPCRouter({
const lessonPlans: { id: string; title: string }[] = [];

lessonPlanItems.forEach(({ section: { lessonPlan } }) => {
// filtering out private lesson plans
if (lessonPlan.private) return;
lessonPlans.push(lessonPlan);
});

Expand Down

0 comments on commit 3182523

Please sign in to comment.