ultraware / roles Goto Github PK
View Code? Open in Web Editor NEWThis project forked from romanbican/roles
Powerful package for handling roles and permissions in Laravel 5
License: MIT License
This project forked from romanbican/roles
Powerful package for handling roles and permissions in Laravel 5
License: MIT License
Hello, I saw that the VerifyPermission is not working properly. Basically it's always returning true event if the user doesn't have the permission.
For example I have two types of roles, the one is admin who has permission on roles route and the client who doesn't have access to role route. Route:
Route::get('/users/roles', ['as' => 'admin.users.roles', 'middleware' => 'permission:edit.roles', 'uses' => 'UsersController@roles']);
If I access the route with the admin is working fine. If I access the route with client it supposed to throw an error but it doesn't, loads the page.
So I did dd($this->auth->user()->userPermissions);
to see the permissions of the client and the permission:edit.roles wasn't in his list.
So I fix it like this
/**
* Handle an incoming request.
*
* @param Request $request
* @param \Closure $next
* @param int|string $permission
* @return mixed
* @throws \Ultraware\Roles\Exceptions\PermissionDeniedException
*/
public function handle($request, Closure $next, $permission) {
$permissionsList = $this->auth->user()->userPermissions->pluck('slug')->toArray();
if ($this->auth->check() && in_array($permission, $permissionsList)) {
return $next($request);
}
throw new PermissionDeniedException($permission);
}
Any chance of an update?
Your requirements could not be resolved to an installable set of packages.
Problem 1
- ultraware/roles 5.5.0 requires laravel/framework 5.5.* -> satisfiable by laravel/framework[5.5.x-dev, v5.5.0, v5.5.1, v5.5.10, v5.5.11, v5.5.12, v5.5.13, v5.5.14, v5.5.15, v5.5.16, v5.5.17, v5.5.18, v5.5.19, v5.5.2, v5.5.20, v5.5.21, v5.5.22, v5.5.23, v5.5.24, v5.5.25, v5.5.26, v5.5.27, v5.5.28, v5.5.29, v5.5.3, v5.5.30, v5.5.31, v5.5.32, v5.5.33, v5.5.34, v5.5.4, v5.5.5, v5.5.6, v5.5.7, v5.5.8, v5.5.9] but these conflict with your requirements or minimum-stability.
- ultraware/roles 5.5.0 requires laravel/framework 5.5.* -> satisfiable by laravel/framework[5.5.x-dev, v5.5.0, v5.5.1, v5.5.10, v5.5.11, v5.5.12, v5.5.13, v5.5.14, v5.5.15, v5.5.16, v5.5.17, v5.5.18, v5.5.19, v5.5.2, v5.5.20, v5.5.21, v5.5.22, v5.5.23, v5.5.24, v5.5.25, v5.5.26, v5.5.27, v5.5.28, v5.5.29, v5.5.3, v5.5.30, v5.5.31, v5.5.32, v5.5.33, v5.5.34, v5.5.4, v5.5.5, v5.5.6, v5.5.7, v5.5.8, v5.5.9] but these conflict with your requirements or minimum-stability.
- Installation request for ultraware/roles ^5.5 -> satisfiable by ultraware/roles[5.5.0].
for example, i need user levels:
1 -> user -> user login (default laravel)
2 -> seller -> seller login (new one for that)
3 -> owner -> web owner login page (another new one for this one too)
and i need all successful redirects to access that login, logout and ect.
lets say:
thanks for help, 'cause i'm new in Laravel and don't understand.
edit:
i have created roles for that with slug and level, but just need different logins.
btw ->
For exemple, actually we can do :
'middleware' => [
'permission:access.site'
]
But what about something like that :
'middleware' => [
'permission:access.site,level:4,role:admin'
]
Convert this to :
IF the user has the permission access.site OR has the level >= 4 OR has the role admin
The user is authorized
ELSE
The user is not authorized
Of course that is just an exemple. But i think we can use that to do complexe permissions without being hard to understand and code.
We can also use the variadic syntax (PHP >= 5.6) to get the parameters ...$permission
and it will return and array :
[
"access.site"
"level:4"
"role:admin"
]
I have thinked about that when i needed to allow guest to access to a page but not certain logged in users releated to a group. (So i have made a custom middleware for that)
Hi, it is possible to add some permissions to a role, and then assign the role to the user.
However, is it possible to disable some of the permissions on the role only for one particular user?
It sounds like a really awesome package.
It is a powerful package for handling roles and permissions in Laravel 5. You really did a good job.
From the composer.json file, it seems that this package doesn't support auto-discovery in Laravel 5.5+, is there any plan to add this feature ?
New Laravel 5.7 was released. Any plans for a version bump? :)
I have a problem, and it is that in my case I do not use the slug, but of uuid and it is manual, I do not use a package, by which when validating it tells me that I do not have permission which is incorrect
$row->name = 'access-admin';
$row->uuid = '79091018328db1b20b89ce6c46ce16ac';
And in the validation tarot look for a defined slug
line 278 of HasRoleAndPermission
public function checkPermission($permission)
{
return $this->getPermissions()->contains(function ($value) use ($permission) {
return $permission == $value->id || Str::is($permission, $value->slug);
});
}
i change the $value->slug
for $value->uuid
The problem is that when updating the package will change the "uuid" by the "slug",as it would in this particular case?
I seem to have the Blade directives @ROLE() etc rendered as text in laravel 5.5 after switching from romanbicans last version.
I have checked the source files for both RolesServiceProvider's registerBladeExtensions function and they are near identical apart from the directory location.
I have migrated from a laravel 5.2 application to 5.5 and upgraded from romanbican's 2.1 version to ultraware's 5.5 version
Schema::create('role_user', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('role_id')->unsigned()->index();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
Schema::create('permission_role', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('permission_id')->unsigned()->index();
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
$table->integer('role_id')->unsigned()->index();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->timestamps();
});
Schema::create('permission_user', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('permission_id')->unsigned()->index();
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
@if (!empty($user->permissions))
@foreach ($user->permissions as $key => $user_perm)
<label class="label label-success">{{ $user_perm->name }}</label>
@endforeach
@endif
no output this
i think we need an update ๐
ultraware/roles 5.3.0 requires illuminate/support 5.3.* -> satisfiable by laravel/framework[v5.3.28], illuminate/support[v5.3.0, v5.3.16, v5.3.23, v5.3.4].
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.