Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { AbilityBuilder, Ability } = require('@casl/ability')
const { toMongoQuery } = require('@casl/mongoose')
const { Forbidden } = require('@feathersjs/errors')
const TYPE_KEY = Symbol.for('type')
Ability.addAlias('update', 'patch')
Ability.addAlias('read', ['get', 'find'])
Ability.addAlias('delete', 'remove')
function subjectName(subject) {
if (!subject || typeof subject === 'string') {
return subject
}
return subject[TYPE_KEY]
}
function defineAbilitiesFor(user) {
const { rules, can } = AbilityBuilder.extract()
can('create',['users'])
can('read', ['posts', 'comments'])
if (user) {
const { AbilityBuilder, Ability } = require('@casl/ability')
const { toMongoQuery } = require('@casl/mongoose')
const { Forbidden } = require('@feathersjs/errors')
const TYPE_KEY = Symbol.for('type')
Ability.addAlias('update', 'patch')
Ability.addAlias('read', ['get', 'find'])
Ability.addAlias('delete', 'remove')
function subjectName(subject) {
if (!subject || typeof subject === 'string') {
return subject
}
return subject[TYPE_KEY]
}
function defineAbilitiesFor(user) {
const { rules, can } = AbilityBuilder.extract()
can('create',['users'])
can('read', ['posts', 'comments'])
const { AbilityBuilder, Ability } = require('@casl/ability')
const { toMongoQuery } = require('@casl/mongoose')
const { Forbidden } = require('@feathersjs/errors')
const TYPE_KEY = Symbol.for('type')
Ability.addAlias('update', 'patch')
Ability.addAlias('read', ['get', 'find'])
Ability.addAlias('delete', 'remove')
function subjectName(subject) {
if (!subject || typeof subject === 'string') {
return subject
}
return subject[TYPE_KEY]
}
function defineAbilitiesFor(user) {
const { rules, can } = AbilityBuilder.extract()
can('create',['users'])
can('read', ['posts', 'comments'])