10000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
背景:前期项目使用 laravel 做服务端,提供 api(粗算了下 route 有 500+),中间一段时间前端开发资源紧张,引入了 DcatAdmin,后端直接写页面。
按文档中提及,共有 3 种方式启用权限:
admin.route.prefix
220413
Route::prefix('xxx_task')->namespace('Goods')->middleware([ 'xxx.refresh', 'admin.permission:allow,administrator,spu-mgr', //`角色`名 role ])->group(function () { Route::get('list', 'XxxTaskController@list'); //其他省略 });
Admin::user()->isRole('developer'); //用户是否有某个角色 Admin::user()->can('create-post'); //是否有某个权限 Admin::user()->cannot('delete-post'); //是否没有某个权限 Admin::user()->isAdministrator(); //是否是超级管理员 Admin::user()->inRoles(['editor', 'developer']); //是否是其中的角色
但是我在使用2方案的时候,遇到了如下问题
2
配置 'admin.permission:allow,administrator,spu-mgr' 在调用中间件的时候,执行如下代码
'admin.permission:allow,administrator,spu-mgr'
// Dcat\Admin\Http\Middleware/Permission public function handle(Request $request, \Closure $next, ...$args) { $user = Admin::user(); if ( ! $user || ! empty($args) // ⚠️ 这里条件判定为 true || ! config('admin.permission.enable') || $this->shouldPassThrough($request) || $user->isAdministrator() || $this->checkRoutePermission($request) ) { // ⚠️ 会走到这里,直接跳过了权限检查… return $next($request); } if (! $user->allPermissions()->first(function ($permission) use ($request) { return $permission->shouldPassThrough($request); })) { Checker::error(); } return $next($request); }
🙏 不知是不是我哪里理解错了…
The text was updated successfully, but these errors were encountered:
方案2确实有问题
Sorry, something went wrong.
然后我只能想办法绕回用 方案 1,但是代码我理解错了,用了 controller.action 这种形式… 还是不行。😔
No branches or pull requests
Description:
背景:前期项目使用 laravel 做服务端,提供 api(粗算了下 route 有 500+),中间一段时间前端开发资源紧张,引入了 DcatAdmin,后端直接写页面。
按文档中提及,共有 3 种方式启用权限:
admin.route.prefix
,220413
我没找到合适的方法但是我在使用
2
方案的时候,遇到了如下问题Steps To Reproduce:
配置
'admin.permission:allow,administrator,spu-mgr'
在调用中间件的时候,执行如下代码🙏 不知是不是我哪里理解错了…
The text was updated successfully, but these errors were encountered: