From 67b33b2640a3d7a5a8914cf15683299fe423f9d4 Mon Sep 17 00:00:00 2001 From: linardsblk <47926386+linardsblk@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:16:40 +0300 Subject: [PATCH] docs: Update casl.js.org linmks to v6 --- content/security/authorization.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/security/authorization.md b/content/security/authorization.md index 1aae181999..a5f7f8c7d6 100644 --- a/content/security/authorization.md +++ b/content/security/authorization.md @@ -253,7 +253,7 @@ export class CaslAbilityFactory { cannot(Action.Delete, Article, { isPublished: true }); return build({ - // Read https://casl.js.org/v5/en/guide/subject-type-detection#use-classes-as-subject-types for details + // Read https://casl.js.org/v6/en/guide/subject-type-detection#use-classes-as-subject-types for details detectSubjectType: (item) => item.constructor as ExtractSubjectType, }); @@ -265,9 +265,9 @@ export class CaslAbilityFactory { > info **Hint** `Ability`, `AbilityBuilder`, `AbilityClass`, and `ExtractSubjectType` classes are exported from the `@casl/ability` package. -> info **Hint** `detectSubjectType` option let CASL understand how to get subject type out of an object. For more information read [CASL documentation](https://casl.js.org/v5/en/guide/subject-type-detection#use-classes-as-subject-types) for details. +> info **Hint** `detectSubjectType` option let CASL understand how to get subject type out of an object. For more information read [CASL documentation](https://casl.js.org/v6/en/guide/subject-type-detection#use-classes-as-subject-types) for details. -In the example above, we created the `Ability` instance using the `AbilityBuilder` class. As you probably guessed, `can` and `cannot` accept the same arguments but have different meanings, `can` allows to do an action on the specified subject and `cannot` forbids. Both may accept up to 4 arguments. To learn more about these functions, visit the official [CASL documentation](https://casl.js.org/v5/en/guide/intro). +In the example above, we created the `Ability` instance using the `AbilityBuilder` class. As you probably guessed, `can` and `cannot` accept the same arguments but have different meanings, `can` allows to do an action on the specified subject and `cannot` forbids. Both may accept up to 4 arguments. To learn more about these functions, visit the official [CASL documentation](https://casl.js.org/v6/en/guide/intro). Lastly, make sure to add the `CaslAbilityFactory` to the `providers` and `exports` arrays in the `CaslModule` module definition: @@ -297,7 +297,7 @@ if (ability.can(Action.Read, 'all')) { } ``` -> info **Hint** Learn more about the `Ability` class in the official [CASL documentation](https://casl.js.org/v5/en/guide/intro). +> info **Hint** Learn more about the `Ability` class in the official [CASL documentation](https://casl.js.org/v6/en/guide/intro). For example, let's say we have a user who is not an admin. In this case, the user should be able to read articles, but creating new ones or removing the existing articles should be prohibited.