stalniy / casl

CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access
https://casl.js.org/
MIT License
5.92k stars 267 forks source link

Update ability JSON #885

Closed roylans closed 7 months ago

roylans commented 7 months ago

I am implementing casl using JSON this is my ability:

import { createMongoAbility } from '@casl/ability'

export default createMongoAbility([
  {
    action: 'read',
    subject: 'all'
  },
])

but I want to update the ability after logging in:


     const rules = .....

      ability.update(rules)
    }

but I don't know how to configure the rules using typescript If anyone can give me a hand I would appreciate it.

stalniy commented 7 months ago

not an issue with casl, please look into https://github.com/stalniy/casl-examples