Closed vahidsabet closed 2 months ago
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen.
I defined ability as following:
const { AbilityBuilder, createMongoAbility } = require('@casl/ability'); module.exports = (user) => { const { can, cannot, build } = new AbilityBuilder(createMongoAbility) if (user) { switch (user.role) { case 'superadm': can('manage', 'all'); break; break; default: can(['read'], ['user']); break; } } return build()
}
In the nodejs and express it's ok but when I use it after API call in Vue3 and user login, it won't work. Login method contains:
const { accessToken, userData, userAbilityRules } = res useCookie('userAbilityRules').value = userAbilityRules ability.update(userAbilityRules)
Describe alternatives you've considered (optional) A clear and concise description of any alternative solutions or features you've considered.
I've used
ability.update([ // switch to readonly mode { action: 'read', subject: 'all' } ])
and it works. But I want get the rules from backend.
Additional context (optional) Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen.
I defined ability as following:
}
In the nodejs and express it's ok but when I use it after API call in Vue3 and user login, it won't work. Login method contains:
Describe alternatives you've considered (optional) A clear and concise description of any alternative solutions or features you've considered.
I've used
and it works. But I want get the rules from backend.
Additional context (optional) Add any other context or screenshots about the feature request here.