Skip to content

Commit

Permalink
chore: complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
paulleonartcalvo committed Sep 19, 2024
1 parent 02793b3 commit 98028b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/casl-ability/spec/error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('`ForbiddenError` class', () => {

it('does not produce error on forbidden action when inverted', () => {
const { error } = setup()
expect(error.unlessCannot('read', 'Post')).toBeUndefined()
expect(error.unlessCannot('archive', 'Post')).toBeUndefined()
})

it('produces an error on allowed action when inverted', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/casl-ability/src/ForbiddenError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export class ForbiddenError<T extends AnyAbility> extends NativeError {
): this | undefined {
const rule = this.ability.relevantRuleFor(action, subject, field);

const isRuleInverted = rule?.inverted ?? false;

if (inverted === isRuleInverted) {
if (inverted && (!rule || rule.inverted)) {
return;
} else if (!inverted && rule && !rule.inverted) {
return;
}

Expand Down

0 comments on commit 98028b0

Please sign in to comment.