Skip to content

Commit

Permalink
check deleted resource perms
Browse files Browse the repository at this point in the history
  • Loading branch information
harishv7 committed Dec 20, 2024
1 parent ffb7c85 commit c70b580
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const definePermissionsForResource = async ({
.selectFrom("ResourcePermission")
.where("userId", "=", userId)
.where("siteId", "=", siteId)
.where("deletedAt", "is", null)

if (!resourceId) {
query = query.where("resourceId", "is", null)
Expand All @@ -50,6 +51,7 @@ export const definePermissionsForSite = async ({
.where("userId", "=", userId)
.where("siteId", "=", siteId)
.where("resourceId", "is", null)
.where("deletedAt", "is", null)
.select("role")
.execute()

Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/server/modules/resource/resource.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export const resourceRouter = router({
.selectFrom("ResourcePermission")
.where("userId", "=", ctx.user.id)
.where("siteId", "=", siteId)
.where("deletedAt", "is", null)

if (!resourceId) {
query.where("resourceId", "is", null)
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/server/modules/site/site.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const siteRouter = router({
return db
.selectFrom("Site")
.innerJoin("ResourcePermission", "Site.id", "ResourcePermission.siteId")
.where("ResourcePermission.deletedAt", "is", null)
.where("ResourcePermission.userId", "=", ctx.user.id)
.select(["Site.id", "Site.name", "Site.config"])
.groupBy(["Site.id", "Site.name", "Site.config"])
Expand Down

0 comments on commit c70b580

Please sign in to comment.