Skip to content

Commit

Permalink
fix: 🐛 store permission on null not possible
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Sep 26, 2024
1 parent 5453e52 commit 3a57167
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/storePermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ export function storePermissions(result: any, abilities: PureAbility<AbilityTupl
}
const actions = ['create', 'read', 'update', 'delete'] as const
const storeProp = (entry: any) => {
entry[prop] = []
actions.forEach((action) => {
if (abilities.can(action, getSubject(model, entry))) {
entry[prop].push(action)
}
})
if (entry) {
entry[prop] = []
actions.forEach((action) => {
if (abilities.can(action, getSubject(model, entry))) {
entry[prop].push(action)
}
})
}
return entry
}
if (Array.isArray(result)) {
Expand Down

0 comments on commit 3a57167

Please sign in to comment.