EQMS-1302: fixed RBAC bypass for space / team related wizards and popups (develop port) (#8979)

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
Victor Ilyushchenko
2025-05-17 01:58:25 +04:00
committed by GitHub
parent ec61340150
commit b79afafa77
7 changed files with 55 additions and 34 deletions
@@ -14,7 +14,7 @@
-->
<script lang="ts">
import { type Doc, type Ref, type Space } from '@hcengineering/core'
import { TypedSpace, type Doc, type Ref, type Space } from '@hcengineering/core'
import documents, {
type DocumentSpace,
type DocumentSpaceType,
@@ -23,7 +23,7 @@
} from '@hcengineering/controlled-documents'
import { SpaceSelector, getClient } from '@hcengineering/presentation'
import { Label } from '@hcengineering/ui'
import { permissionsStore } from '@hcengineering/contact-resources'
import { checkMyPermission, permissionsStore } from '@hcengineering/contact-resources'
import { $locationStep as locationStep, locationStepUpdated } from '../../../stores/wizards/create-document'
import DocumentParentSelector from '../../hierarchy/DocumentParentSelector.svelte'
@@ -82,9 +82,9 @@
$: canProceed = $locationStep.space !== undefined && $locationStep.project !== undefined
$: hasParentSelector = $locationStep.space !== documents.space.UnsortedTemplates
$: restrictedSpaces = Object.entries($permissionsStore.ps)
.filter(([, pss]) => !pss.has(documents.permission.CreateDocument))
.map(([s]) => s) as Ref<Space>[]
$: restrictedSpaces = Object.keys($permissionsStore.ps).filter(
(s) => !checkMyPermission(documents.permission.CreateDocument, s as Ref<TypedSpace>, $permissionsStore)
) as Ref<TypedSpace>[]
$: spaceQuery = isTemplate
? { _id: { $nin: restrictedSpaces }, archived: false, _class: { $nin: externalSpaces } }