Comments (6)
is_a(User::first(), get_class(app(Spatie\Permission\PermissionRegistrar::class)->getRoleClass())) [!] Aliasing 'User' to 'App\Models\User' for this Tinker session. = false
It is not necessary to clear the cache when assigning permissions to an user, because this action does not change anything in the cache, the cache is only cleared when permissions are created/deleted/modified, or when permissions are assigned/removed to a role.
from laravel-permission.
@parallels999 it is, i have failing tests because of this issue, i had to manually clear the cache :
$user->givePermissionTo(['abc']);
app()->make(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
i will try to dig deaper to understand why
from laravel-permission.
It is an expected behavior, not an issue
$user->givePermissionTo(['abc']); app()->make(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
I don't see it necessary, you should do that in the seeder,
try this:
app()->make(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
$user->givePermissionTo(['abc']);
It sure works the same
from laravel-permission.
There is an impact, because i can see the permissions of the user when calling getPermissions
yet calling $user->can('mypermission')
return false for some reason
from laravel-permission.
Maybe
laravel-permission/tests/TestCase.php
Line 86 in 62f22e1
from laravel-permission.
the issue is solved now, and i cant reproduce it anymore, perhaps an issue with redis i don't know, but i could clearly call $user->getPermissionNames()
and see my permissions while $user->can()
was still returning false
from laravel-permission.
Related Issues (20)
- assignRole and syncRoles fail for model with ulid type id HOT 2
- Documentation for v6/main unaccessible at spatie.be HOT 4
- Wrong octane event listener HOT 2
- Too much Role-Models loaded HOT 3
- Enums shouldn't be casted in the model HOT 8
- assignRole > getModel() > null
- Timestamps in migration for sql server HOT 4
- Target class [Spatie\Permission\Middlewares\PermissionMiddleware] does not exist. HOT 2
- DOCS - Side menu dissapeared HOT 4
- Problem upgrading with existing data permissions/roles HOT 1
- Cannot save the user model twice in the same request HOT 10
- withoutPermission scope from HasPermissions returns users from outside the team HOT 3
- Laravel 11 compatibility issues HOT 5
- Problem with middleware definition method in the controller in Laravel 11
- Problem with denied access using the middleware aliases role, permission, and role_or_permission in Spatie Permission version 6 and higher. HOT 2
- Problem when trying to migrate laravel-permission migrations HOT 2
- Docs are not uptodate with current implementation HOT 9
- Diffs are not properly displayed in generated docs HOT 4
- Bug @can OR $user->can OR $user->hasAnyPermission($permission) HOT 1
- Problems giving permissions to a role when the id field is a uuid type HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-permission.