提交 28e8657b 编写于 作者: E eddy8

fix: permission check crashed when menu does not exist

上级 d47d933f
......@@ -22,7 +22,7 @@ class Authorization
$user = Auth::guard($guard)->user();
$route = Route::currentRouteName();
$permission = Menu::where('route', $route)->first();
if (!in_array($user->id, config('light.superAdmin')) && !$user->can($permission->name)) {
if (!in_array($user->id, config('light.superAdmin')) && (!$permission || !$user->can($permission->name))) {
if ($request->expectsJson()) {
return response()->json(['code' => 401, 'msg' => "未授权操作(路由别名:{$route})"], 401);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册