【发布时间】:2018-08-01 08:15:24
【问题描述】:
我正在使用 Sentinel 进行身份验证。只要我登录,一切正常。但是当我注销时(删除persistences 表中的所有值)并且我在something.blade.php 上并单击触发发布请求的link(请参阅下面的代码sn-p),我会得到转发到登录页面。登录后,我收到以下 Laravel 错误:
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
路由在web.php:
Route::post('something/{xtype}/{xid}/execute/{yid}', 'MyController@execute');
MyController.php 中的控制器逻辑:
public function execute($xtype, $xid, $yid)
{
// business logic
return back();
}
查看something.blade.php:
<form action="/something/{{ $something->xtype }}/{{ $something->xid }}/execute/{{ $others->yid }}" method="POST" id="y_{{ $others->yid }}">
{!! csrf_field() !!}
</form>
<a type="button" href="#" onClick="document.getElementById('y_{{ $others->yid }}').submit()">
中间件AdminMiddleware.php:
public function handle($request, Closure $next)
{
if (Sentinel::check())
{
if (Sentinel::getUser()->roles()->first()->slug == 'admin')
{
return $next($request);
}
}
return redirect()->guest('/login')
->with(['error' => "You do not have the permission.."]);
}
}
编辑:
登录后,我会遇到LoginController,然后会执行以下代码:
return redirect()->intended($fallbackUrl);
由于我还是 Laravel 的新手,我很难在框架内部进行深入调试。您有什么想法/建议吗?
欢迎一切!提前致谢!
【问题讨论】:
标签: php laravel laravel-5 cartalyst-sentinel