Reputation: 167
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.
Upvotes: 0
Views: 646
Reputation: 167
The problem was caused because of the order in the Kernel.php $middlewareGroups
where \Keevitaja\Linguist\LocalizeUrls::class
was on first position.
Upvotes: 1