Skip to content

Commit ccc8305

Browse files
authored
chore: log user id + validate permmissions for publish (#1323)
1 parent 28cfd9f commit ccc8305

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

apps/studio/src/server/modules/page/page.router.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,19 @@ export const pageRouter = router({
534534

535535
publishPage: protectedProcedure
536536
.input(publishPageSchema)
537-
.mutation(async ({ ctx, input: { siteId, pageId } }) =>
538-
publishPageResource(ctx.logger, siteId, String(pageId), ctx.user.id),
539-
),
537+
.mutation(async ({ ctx, input: { siteId, pageId } }) => {
538+
await validateUserPermissionsForResource({
539+
userId: ctx.user.id,
540+
siteId,
541+
action: "update",
542+
})
543+
return publishPageResource(
544+
ctx.logger,
545+
siteId,
546+
String(pageId),
547+
ctx.user.id,
548+
)
549+
}),
540550

541551
updateMeta: protectedProcedure
542552
.input(updatePageMetaSchema)

apps/studio/src/server/modules/resource/resource.router.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ export const resourceRouter = router({
527527
const user = await db
528528
.selectFrom("User")
529529
.selectAll()
530+
.where("id", "=", ctx.user.id)
530531
.executeTakeFirstOrThrow(
531532
() =>
532533
new TRPCError({

0 commit comments

Comments
 (0)