mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +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 AccountsByPermission = Record<Ref<Space>, Record<Ref<Permission>, Set<Ref<Account>>>>
|
||||
interface PermissionsStore {
|
||||
export interface PermissionsStore {
|
||||
ps: PermissionsBySpace
|
||||
ap: AccountsByPermission
|
||||
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>({
|
||||
ps: {},
|
||||
ap: {},
|
||||
|
Loading…
Reference in New Issue
Block a user