laravel-acl
laravel-acl copied to clipboard
Added: Different guard support
This fixes handling of a different guard other than application default.
Fixes: #135.
- Guard parameter on config file to get default;
/**
* Guard
* Set the guard for user validations.
*/
'guard' => config('auth.defaults.guard'),
- Added guard on HasPermission handle;
$this->guard = config('acl.guard');
-
Added
$guard = $this->guardon hasRole, hasPermission and protectMethods; -
Changed
$request->user()to$request->user($guard)on hasRole, hasPermission and protectMethods; -
Changed Blade directives to
Blade::ifmethod and guard added;
// role
Blade::if('role', function ($expression) {
return Auth::guard(config('acl.guard'))->check() && Auth::guard(config('acl.guard'))->user()->hasRole($expression);
});
// permission
Blade::if('permission', function ($expression) {
return Auth::guard(config('acl.guard'))->check() && Auth::guard(config('acl.guard'))->user()->hasPermission($expression);
});
@CodeIgor could you please update the readme file as well to support this update
@kodeine Sure, feel free to tell me if there is something else needed Update README.md
@CodeIgor sorry for very late reply, it just slipped from my todo list.
So, endpermission and endrole was removed, can we make it backwards compatible?
@kodeine done, i changed the used directive back to how it was but with the guard method call
Thank you!