This document now exists on the official ASP.NET core docs page.
- Application
- Request Handling
This document now exists on the official ASP.NET core docs page.
| export function magicMethods (clazz) { | |
| // A toggle switch for the __isset method | |
| // Needed to control "prop in instance" inside of getters | |
| let issetEnabled = true | |
| const classHandler = Object.create(null) | |
| // Trap for class instantiation | |
| classHandler.construct = (target, args, receiver) => { | |
| // Wrapped class instance |
| import { AbilityBuilder, Ability } from 'casl' | |
| // Alternatively this data can be retrieved from server | |
| export default function defineAbilitiesFor(user) { | |
| const { rules, can } = AbilityBuilder.extract() | |
| can('read', 'User') | |
| can('update', 'User', { id: user.id }) | |
| if (user.role === 'doctor') { |