Skip to content

Commit

Permalink
kjkhj
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Feb 15, 2023
1 parent d781399 commit aa18463
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/web-pkg/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type ReadOnlyRef<T> = Readonly<Ref<T>>
export type MaybeRef<T> = T | Ref<T>
export type MaybeReadonlyRef<T> = MaybeRef<T> | ReadOnlyRef<T>

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]>
5 changes: 4 additions & 1 deletion packages/web-runtime/src/services/auth/userManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ export class UserManager extends OidcUserManager {
private updateUserAbilities(user) {
const rules: SubjectRawRule<Actions, Subjects, any>[] = []

// 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)
}
}

0 comments on commit aa18463

Please sign in to comment.