Skip to content

Commit e6dbba9

Browse files
authored
fix: update PermissionsProvider to use site perms instead of resource perms (#1528)
* fix: update resourceId handling in PermissionsProvider to use site role instead of resource role * undo * move perms check logic
1 parent 83d0461 commit e6dbba9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

apps/studio/src/server/modules/permissions/__tests__/permissions.service.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,8 @@ describe("getResourcePermission", () => {
10511051
expect(permissions[0]?.role).toBe(RoleType.Admin)
10521052
})
10531053

1054-
it("should return resource-specific permissions when resourceId is provided", async () => {
1054+
// TODO: add this back in when we have resource-specific permissions
1055+
it.skip("should return resource-specific permissions when resourceId is provided", async () => {
10551056
// Arrange
10561057
const user = await setupUser({ email: "[email protected]" })
10571058
const { page, site } = await setupPageResource({
@@ -1115,7 +1116,8 @@ describe("getResourcePermission", () => {
11151116
expect(permissions).toHaveLength(0)
11161117
})
11171118

1118-
it("should not return site-wide permissions when resourceId is provided and is not null", async () => {
1119+
// TODO: add this back in when we have resource-specific permissions
1120+
it.skip("should not return site-wide permissions when resourceId is provided and is not null", async () => {
11191121
// Arrange
11201122
const user = await setupUser({ email: "[email protected]" })
11211123
const { page, site } = await setupPageResource({

apps/studio/src/server/modules/permissions/permissions.service.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,17 @@ export const bulkValidateUserPermissionsForResources = async ({
165165
export const getResourcePermission = async ({
166166
userId,
167167
siteId,
168-
resourceId,
168+
resourceId: _resourceId,
169169
}: PermissionsProps) => {
170170
let query = db
171171
.selectFrom("ResourcePermission")
172172
.where("userId", "=", userId)
173173
.where("siteId", "=", siteId)
174174
.where("deletedAt", "is", null)
175175

176-
if (resourceId) {
177-
query = query.where("resourceId", "=", resourceId)
178-
} else {
179-
query = query.where("resourceId", "is", null)
180-
}
176+
// NOTE: we are using site-wide permissions for now
177+
// because there's no granular resource role
178+
query = query.where("resourceId", "is", null)
181179

182180
return query.select("role").execute()
183181
}

0 commit comments

Comments
 (0)