记一次神奇的 bug,无限 302 重定向
一切按照教程走,居然出现了无限302,user和admin两个地址互相重定向的问题。于是各种检查问题,甚至复制粘贴情况仍旧出现。
后来追到源码中发现。
在Frozennode\Administrator\Http\Middleware
中
public function handle($request, Closure $next)
{
$config = app('itemconfig');
//if the model doesn't exist at all, redirect to 404
if (!$config) {
abort(404, 'Page not found');
}
//check the permission
$p = $config->getOption('permission');
//if the user is simply not allowed permission to this model, redirect them to the dashboard
if (!$p) {
return redirect()->route('admin_dashboard');
}
/**这里的$p是子菜单users的权限**/
//get the settings data if it's a settings page
if ($config->getType() === 'settings') {
$config->fetchData(app('admin_field_factory')->getEditFields());
}
//otherwise if this is a response, return that
if (is_a($p, 'Illuminate\Http\JsonResponse') || is_a($p, 'Illuminate\Http\Response') || is_a($p, 'Illuminate\\Http\\RedirectResponse')) {
return $p;
}
return $next($request);
}
最终发现是,manage_users
少了一个s
,于是造成了用户有后台的进入权限,但是没有users菜单的权限。
但是进入后台的首页被重定向到了users页面,而users页面在没有权限的时候,根据return redirect()->route('admin_dashboard');
可见被重定向到了菜单主页,也就是http://larabbs.test/admin
,自此循环重定向构成。
所以能后台管理的用户一定也要有默认菜单的访问权限呀。(手动掩面)
推荐文章: