dimanche 26 novembre 2017

Sentinel::check() always return FALSE in middleware

This is my route:

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

This is my modification in 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");

I am using Sentinel and Linguist for authentication and localisation. I would like to get 'system_language' from the User model: check if the user is logged in and if he is, I would like to get his preferred language from the DB and then pass it to Linguist:

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

Unfortunately, Sentinel:check() always returns FALSE in this middleware. In my own middleware it is working well.

For sure, I am using the right Facade of Sentinel, because $sentinel = Sentinel::findById(1); returns a valid result.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2n2SCZz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire