Skip to content

Subject Hooks won't fire if there are no 'conditions' setup in the rule #923

@vineetmago

Description

@vineetmago

I was trying to setup a class based Subject Hook on a rule without conditions but wasn't able to get it working.

The bundled test case uses the following permission spec:
can(Actions.update, Post, { userId: user.id });

if the test case is setup us as the following spec instead, the PostHook wouldn't fire:
can(Actions.update, Post);

Please review the line access.service.ts #99

if (!relevantRules.every((rule) => rule.conditions) || !ability.subjectHook) {

Should it having an AND (&&) condition instead of an OR (||) ? This condition doesn't allow rules without conditions to specify a SubjectHook.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions