Category : permissions

h have problem when try to step laratrust with laravel 7 Your requirements could not be resolved to an installable set of packages. Problem 1 – santigarcor/laratrust[5.0.0, …, 5.0.x-dev] require illuminate/auth ~5.2 -> found illuminate/auth[v5.2.0, …, 5.8.x-dev] but these were not loaded, likely because it conflicts with another require. – Root composer.json requires santigarcor/laratrust 5.0.* ..

Read more

Sorry because my English is weak and I can not speak well!! This is the route I defined on the web.php page : <?php use AppHttpControllersController; use AppHttpControllersGoogleAuthController; use AppHttpControllersProfileController; use AppHttpControllersUrlController; use IlluminateSupportFacadesAuth; use IlluminateSupportFacadesRoute; /* |————————————————————————– | Web Routes |————————————————————————– | | Here is where you can register web routes for your application. ..

Read more

can u help me pls? Added spatie/laravel-permission, everything works by middleware in routes/api.php Route::get(‘roles’, [RoleController::class, ‘rolesIndex’])->middleware(‘role:Admin’); I wanted to make a role check for api and added a function: function check($roleName) { $user = Auth::user(); if (!$user->hasRole($roleName)) { abort(403); } return response(”, 202); } Added to the router – addressing the route: Route::get(‘check/{roleName}’, [RoleController::class, ‘check’]); ..

Read more

When I’m creating new users and assign them roles and permissions it works fine, but when I assign role using protected route Route::post(‘/excel/upload’, [ExcelController::class,’upload’])->name(‘uploadExcel’)->middleware(‘auth:sanctum’); i get and error: SpatiePermissionExceptionsGuardDoesNotMatch The given role or permission should use guard web instead of sanctum. auth.php ‘defaults’ => [ ‘guard’ => ‘web’, ‘passwords’ => ‘users’, ], ‘guards’ => [ ..

Read more

I’m new to react and I’m using an authentication example that controls user permissions using casl/ability. In the example, an authentication in JWT is presented that reads the following JSON structure: users: [ { id: 1, fullName: ‘John’, username: ‘john’, password: ‘admin’, email: ‘[email protected]’, role: ‘admin’, ability: [ { action: ‘manage’, subject: ‘all’ } ] ..

Read more

I’m currently working on a laravel project "canteen’. I used a plugin named Spatie to create roles permissions system. This plugin has its own tables from migration like roles, permissions, role_has_permissions, model_has_roles and model_has_permissions. picture example inserting roles to an user I want to make roles Admin, Teacher, Student and Seller. Me as Admin can ..

Read more

I have an Laravel app with about 30 permissions. App also uses plenty of endpoints. Now I want to write feature tests for each endpoint, checking every permission on it. There is my question: Should I write separate method for each permission like that: public function test_if_user_can_create_article_having_articles_index_permission() { $user = $this->makeUserWithSuchPermisssion(); $this->actingAs($user)->post(‘/articles’)->assertStatus(403) } public function ..

Read more

Hey I am developing a project where I have roles and permissions for users and I am trying to protect my routes with the help of middleware by defining Gates but it’s showing me 403| Not Authorized. I can’t understand what the actual problem is? Into Category Controller public function addcategory(AdminsRole $adminsroles){ return view(‘add-category’); } ..

Read more

I need to grant access to users with different roles to actions of one resource. I tried the following but no luck in web.php routes file: Route::resource(‘trampas’, ‘TrampaController’)->middleware(‘role:Administrador|Supervisor’); //Access to all actions Route::resource(‘trampas’, ‘TrampaController’)->middleware(‘role:Monitoreador|Coordinador’)->only(‘index’, ‘show’); But when i declare the 2nd line the first in annulled. Same thing happens when it’s declared in the controller’s ..

Read more

There are a lot of articles about this, I read them but none of the solutions worked. I have laravel mounted via docker-compose in the folder /var/www/html/app I am using this docker image https://github.com/khromov/alpine-nginx-php8/blob/master/Dockerfile Logged into the container as root user with docker-compose exec -u root web sh, I can gave 777 permission to all ..

Read more

$ mv deployer.phar /usr/local/bin/dep This command has shown the below error. mv: cannot move ‘deployer.phar’ to ‘/usr/local/bin/dep’: No such file or directory So, I tried mentioning a different location. Now, it shows the permission denied error. $ mv deployer.phar /downloads mv: cannot move ‘deployer.phar’ to ‘/downloads’: Permission denied I am using windows 10. Please help ..

Read more

In my application, I’ve used the Sentinel package for authorization. Now I need an API to retrieve user permissions for an expected JSON structure. expected JSON structure: { "user_id": 3172, "first_name": "Bonny", "last_name": "Hewage", "username": "bonny", "user_roles": [ { "id": 2, "slug": "store-user", "name": "Store User", "permissions": {"user.create":true, "user.update":true} }, { "id": 6, "slug": "mu-supervisor", ..

Read more

I am trying to upload a file (PDF document) using Laravel. However I am keep on getting the below error: file_get_contents(/tmp/phpQcAqB6): failed to open stream: Permission denied Below I have provided a dump of the IlluminateHttpRequest object, this is what is getting passed into my controller when uploading the document: Array ( [file] => /tmp/phpQcAqB6 ..

Read more