Skip to content

Commit 59e94f9

Browse files
committed
refactor(plugins): add error logs to upvote downvote mutations
1 parent 9e3013d commit 59e94f9

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

src/generated/graphql/schema.executable.ts

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const spec_downvote = {
154154
},
155155
description: undefined,
156156
extensions: {
157-
oid: "230048",
157+
oid: "230322",
158158
isTableLike: true,
159159
pg: {
160160
serviceName: "main",
@@ -237,7 +237,7 @@ const spec_upvote = {
237237
},
238238
description: undefined,
239239
extensions: {
240-
oid: "229961",
240+
oid: "230235",
241241
isTableLike: true,
242242
pg: {
243243
serviceName: "main",
@@ -320,7 +320,7 @@ const spec_invitation = {
320320
},
321321
description: undefined,
322322
extensions: {
323-
oid: "230147",
323+
oid: "230421",
324324
isTableLike: true,
325325
pg: {
326326
serviceName: "main",
@@ -403,7 +403,7 @@ const spec_organization = {
403403
},
404404
description: undefined,
405405
extensions: {
406-
oid: "229923",
406+
oid: "230197",
407407
isTableLike: true,
408408
pg: {
409409
serviceName: "main",
@@ -510,7 +510,7 @@ const spec_comment = {
510510
},
511511
description: undefined,
512512
extensions: {
513-
oid: "230028",
513+
oid: "230302",
514514
isTableLike: true,
515515
pg: {
516516
serviceName: "main",
@@ -629,7 +629,7 @@ const spec_project = {
629629
},
630630
description: undefined,
631631
extensions: {
632-
oid: "229947",
632+
oid: "230221",
633633
isTableLike: true,
634634
pg: {
635635
serviceName: "main",
@@ -650,7 +650,7 @@ const roleCodec = enumCodec({
650650
values: ["owner", "admin", "member"],
651651
description: undefined,
652652
extensions: {
653-
oid: "230067",
653+
oid: "230341",
654654
pg: {
655655
serviceName: "main",
656656
schemaName: "public",
@@ -729,7 +729,7 @@ const spec_member = {
729729
},
730730
description: undefined,
731731
extensions: {
732-
oid: "229983",
732+
oid: "230257",
733733
isTableLike: true,
734734
pg: {
735735
serviceName: "main",
@@ -860,7 +860,7 @@ const spec_post = {
860860
},
861861
description: undefined,
862862
extensions: {
863-
oid: "229937",
863+
oid: "230211",
864864
isTableLike: true,
865865
pg: {
866866
serviceName: "main",
@@ -979,7 +979,7 @@ const spec_postStatus = {
979979
},
980980
description: undefined,
981981
extensions: {
982-
oid: "230121",
982+
oid: "230395",
983983
isTableLike: true,
984984
pg: {
985985
serviceName: "main",
@@ -1000,7 +1000,7 @@ const tierCodec = enumCodec({
10001000
values: ["free", "basic", "team", "enterprise"],
10011001
description: undefined,
10021002
extensions: {
1003-
oid: "230170",
1003+
oid: "230444",
10041004
pg: {
10051005
serviceName: "main",
10061006
schemaName: "public",
@@ -1129,7 +1129,7 @@ const spec_user = {
11291129
},
11301130
description: undefined,
11311131
extensions: {
1132-
oid: "229971",
1132+
oid: "230245",
11331133
isTableLike: true,
11341134
pg: {
11351135
serviceName: "main",
@@ -4326,7 +4326,12 @@ const planWrapper7 = (plan, _, fieldArgs) => {
43264326
downvotes
43274327
} = lib_drizzle_schema,
43284328
[downvote] = await db.select().from(downvotes).where(eq(downvotes.id, downvoteId));
4329-
if (currentUser.id !== downvote.userId) throw new Error("Insufficient permissions");
4329+
if (currentUser.id !== downvote.userId) {
4330+
console.error("Current User ID", currentUser.id);
4331+
console.error("Downvote User ID", downvote.userId);
4332+
console.error("Downvote Row ID", downvote.id);
4333+
throw new Error("Insufficient permissions");
4334+
}
43304335
});
43314336
return plan();
43324337
};
@@ -4349,7 +4354,12 @@ const planWrapper8 = (plan, _, fieldArgs) => {
43494354
upvotes
43504355
} = lib_drizzle_schema,
43514356
[upvote] = await db.select().from(upvotes).where(eq(upvotes.id, upvoteId));
4352-
if (currentUser.id !== upvote.userId) throw new Error("Insufficient permissions");
4357+
if (currentUser.id !== upvote.userId) {
4358+
console.error("Current User ID", currentUser.id);
4359+
console.error("Upvote User ID", upvote.userId);
4360+
console.error("Upvote Row ID", upvote.id);
4361+
throw new Error("Insufficient permissions");
4362+
}
43534363
});
43544364
return plan();
43554365
};
@@ -4646,7 +4656,12 @@ const planWrapper16 = (plan, _, fieldArgs) => {
46464656
downvotes
46474657
} = lib_drizzle_schema,
46484658
[downvote] = await db.select().from(downvotes).where(eq(downvotes.id, downvoteId));
4649-
if (currentUser.id !== downvote.userId) throw new Error("Insufficient permissions");
4659+
if (currentUser.id !== downvote.userId) {
4660+
console.error("Current User ID", currentUser.id);
4661+
console.error("Downvote User ID", downvote.userId);
4662+
console.error("Downvote Row ID", downvote.id);
4663+
throw new Error("Insufficient permissions");
4664+
}
46504665
});
46514666
return plan();
46524667
};
@@ -4669,7 +4684,12 @@ const planWrapper17 = (plan, _, fieldArgs) => {
46694684
upvotes
46704685
} = lib_drizzle_schema,
46714686
[upvote] = await db.select().from(upvotes).where(eq(upvotes.id, upvoteId));
4672-
if (currentUser.id !== upvote.userId) throw new Error("Insufficient permissions");
4687+
if (currentUser.id !== upvote.userId) {
4688+
console.error("Current User ID", currentUser.id);
4689+
console.error("Upvote User ID", upvote.userId);
4690+
console.error("Upvote Row ID", upvote.id);
4691+
throw new Error("Insufficient permissions");
4692+
}
46734693
});
46744694
return plan();
46754695
};

src/lib/plugins/postgraphile/DownvoteRBAC.plugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const validatePermissions = (propName: string) =>
3333

3434
// Only allow the user who downvoted to update or delete their own downvote
3535
if (currentUser.id !== downvote.userId) {
36+
console.error("Current User ID", currentUser.id);
37+
console.error("Downvote User ID", downvote.userId);
38+
console.error("Downvote Row ID", downvote.id);
39+
3640
throw new Error("Insufficient permissions");
3741
}
3842
},

src/lib/plugins/postgraphile/UpvoteRBAC.plugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const validatePermissions = (propName: string) =>
3333

3434
// Only allow the user who upvoted to update or delete their own upvote
3535
if (currentUser.id !== upvote.userId) {
36+
console.error("Current User ID", currentUser.id);
37+
console.error("Upvote User ID", upvote.userId);
38+
console.error("Upvote Row ID", upvote.id);
39+
3640
throw new Error("Insufficient permissions");
3741
}
3842
},

0 commit comments

Comments
 (0)