From aa1846394c68e5e4200c45fe2f85c6f72332d3ea Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 15 Feb 2023 10:08:29 +0100 Subject: [PATCH] kjkhj --- packages/web-pkg/src/utils/types.ts | 4 ++-- packages/web-runtime/src/services/auth/userManager.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/web-pkg/src/utils/types.ts b/packages/web-pkg/src/utils/types.ts index ccc9e4f7410..778906ed484 100644 --- a/packages/web-pkg/src/utils/types.ts +++ b/packages/web-pkg/src/utils/types.ts @@ -5,7 +5,7 @@ export type ReadOnlyRef = Readonly> export type MaybeRef = T | Ref export type MaybeReadonlyRef = MaybeRef | ReadOnlyRef -export type Actions = 'create' | 'read' | 'update' | 'delete' | 'manage' -export type Subjects = 'Space' +export type Actions = 'create' | 'read' | 'update' | 'delete' | 'manage' | 'set-quota' +export type Subjects = 'Setting' | 'Space' | 'User' export type Ability = MongoAbility<[Actions, Subjects]> diff --git a/packages/web-runtime/src/services/auth/userManager.ts b/packages/web-runtime/src/services/auth/userManager.ts index 54916041e75..67ae9fc91e8 100644 --- a/packages/web-runtime/src/services/auth/userManager.ts +++ b/packages/web-runtime/src/services/auth/userManager.ts @@ -276,11 +276,14 @@ export class UserManager extends OidcUserManager { private updateUserAbilities(user) { const rules: SubjectRawRule[] = [] - // TODO: expand capabilities if (!!user.role?.settings.find((s) => s.name === 'create-space')) { rules.push({ action: 'create', subject: 'Space' }) } + if (!!user.role?.settings.find((s) => s.name === 'set-space-quota')) { + rules.push({ action: 'set-quota', subject: 'Space' }) + } + this.$ability.update(rules) } }