mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
EZQMS-663: Add permissions util (#5189)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
dc580157c6
commit
4379549291
@ -1333,12 +1333,16 @@ async function getAttrEditor (key: KeyedAttribute, hierarchy: Hierarchy): Promis
|
|||||||
|
|
||||||
type PermissionsBySpace = Record<Ref<Space>, Set<Ref<Permission>>>
|
type PermissionsBySpace = Record<Ref<Space>, Set<Ref<Permission>>>
|
||||||
type AccountsByPermission = Record<Ref<Space>, Record<Ref<Permission>, Set<Ref<Account>>>>
|
type AccountsByPermission = Record<Ref<Space>, Record<Ref<Permission>, Set<Ref<Account>>>>
|
||||||
interface PermissionsStore {
|
export interface PermissionsStore {
|
||||||
ps: PermissionsBySpace
|
ps: PermissionsBySpace
|
||||||
ap: AccountsByPermission
|
ap: AccountsByPermission
|
||||||
whitelist: Set<Ref<Space>>
|
whitelist: Set<Ref<Space>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function checkMyPermission (_id: Ref<Permission>, space: Ref<TypedSpace>, store: PermissionsStore): boolean {
|
||||||
|
return (store.whitelist.has(space) || store.ps[space]?.has(_id)) ?? false
|
||||||
|
}
|
||||||
|
|
||||||
export const permissionsStore = writable<PermissionsStore>({
|
export const permissionsStore = writable<PermissionsStore>({
|
||||||
ps: {},
|
ps: {},
|
||||||
ap: {},
|
ap: {},
|
||||||
|
Loading…
Reference in New Issue
Block a user