You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Users are not allowed to set how to detect subject type when they are building abilities. It may cause the wrong subject type detection and get an unpredictable result.
it('test',async()=>{expect(accessService.hasAbility(user,Actions.delete,newPost())).toBeTruthy();// not pass});
The test above would not pass but can be solved by the below solutions.
ability.factory.ts
...
// For PureAbility skip conditions check, conditions will be available for filtering through @CaslConditions() paramif(abilityClass===PureAbility){returnability.build({conditionsMatcher: nullConditionsMatcher,detectSubjectType: object=>object.constructorasExtractSubjectType<Subjects>});}returnability.build({detectSubjectType: object=>object.constructorasExtractSubjectType<Subjects>});
In addition to that, can we update the library to support string as the subject type? CASL by nature supports that. Currently, this library only accepts class types, making typescript complain when providing string types, although the code works.
Users are not allowed to set how to detect subject type when they are building abilities. It may cause the wrong subject type detection and get an unpredictable result.
casl docs
e.g.
The test above would not pass but can be solved by the below solutions.
ability.factory.ts
or
The text was updated successfully, but these errors were encountered: