Sentinel :: check()总是在中间件中返回FALSE

问题描述 投票:0回答:1

这是我的路线:

Route::group(['middleware' => ['web']], function () {
    Route::get('/xx', 'xx\yy@zz');

这是我在Kernel.php中的修改:

protected $middlewareGroups = [
    'web' => [
    \Keevitaja\Linguist\LocalizeUrls::class,

LocalizeUrls.php:

public function handle($request, Closure $next)
    {
        if ($this->linguist->hasDefaultSlug() && $this->linguist->isDefaultDenied()) {
            abort(404);
        }

        if (Sentinel::check())
        {
            dd("logged in");
        }

        dd("NOT logged in");

我正在使用Sentinel和Linguist进行身份验证和本地化。我想从User模型中获取'system_language':检查用户是否已登录,如果他是,我想从DB中获取他的首选语言,然后将其传递给Linguist:

$this->linguist->localize('fr');

不幸的是,Sentinel:check()总是在这个中间件中返回FALSE。在我自己的中间件中,它运行良好。

当然,我正在使用正确的前哨门面,因为$sentinel = Sentinel::findById(1);会返回有效的结果。

php laravel laravel-5 cartalyst-sentinel
1个回答
1
投票

问题是由于Kernel.php $middlewareGroups\Keevitaja\Linguist\LocalizeUrls::class位于第一位置的顺序引起的。

© www.soinside.com 2019 - 2024. All rights reserved.