Skip to content

Commit

Permalink
[Docs] formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte authored Apr 8, 2023
1 parent fa4beb1 commit bc9fff8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/advanced-usage/custom-permission-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ title: Custom Permission Check
weight: 6
---

By default, a method is registered on [Laravel's gate](https://laravel.com/docs/authorization). This method is responsible for checking if the user has the required permission or not. Whether a user has a permission or not is determined by checking the user's permissions stored in the database.
By default, this package registers a `Gate::before()` method call on [Laravel's gate](https://laravel.com/docs/authorization). This method is responsible for checking if the user has the required permission or not, for calls to `can()` helpers and most `model policies`. Whether a user has a permission or not is determined by checking the user's permissions stored in the database.

However, in some cases, you might want to implement custom logic for checking if the user has a permission or not.

Let's say that your application uses access tokens for authentication and when issuing the tokens, you add a custom claim containing all the permissions the user has. In this case, if you want to check whether the user has the required permission or not based on the permissions in your custom claim in the access token, then you need to implement your own logic for handling this.

You could, for example, create a `before` method to handle this:
You could, for example, create a `Gate::before()` method call to handle this:

**app/Providers/AuthServiceProvider.php**
```php
Expand All @@ -22,8 +22,9 @@ public function boot()
});
}
```
Here `hasTokenPermission` is a custom method you need to implement yourself.
Here `hasTokenPermission` is a **custom method you need to implement yourself**.

### Register Permission Check Method
By default, `register_permission_check_method` is set to `true`.
Only set this to false if you want to implement custom logic for checking permissions.
By default, `register_permission_check_method` is set to `true`, which means this package operates using the default behavior described earlier.

Only set this to false if you want to bypass the default operation and implement your own custom logic for checking permissions.

0 comments on commit bc9fff8

Please sign in to comment.