rydurham / Sentinel

A Sentry bridge package for Laravel
http://www.ryandurham.com/projects/sentinel/
317 stars 68 forks source link

laravel 5.2 Sentry::check() not working #197

Closed cryptoBOOOOM closed 8 years ago

cryptoBOOOOM commented 8 years ago

Sentry::check() always returns false....

@if(Sentry::check())
<li><a href="#">{{Sentry::getUser()->email}}</a></li>
<li><a href="{{url('logout')}}">Logout</a></li>
@else
<li><a href="{{url('login')}}">Login</a></li>
@endif
rydurham commented 8 years ago

Is this happening on a route that is provided with Sentinel or a separate route that is part of your application?

cryptoBOOOOM commented 8 years ago

its happening everywhere, i created two laravel 5.2 projects yesterday with all the same setup: bootstrap + sentinel.

In my master template i included the code you see in my first post. But also when i dd(Sentry::getUser()) it returns null...

rydurham commented 8 years ago

I have only been able to replicate this when I try it on a route that does not go through the laravel middleware. Are you using the "web" middleware group and still having this problem?

kamaroly commented 8 years ago

In your route make sure you group by web middleware like below, then make sure you are using sentry laravel facade full namespace like \Sentry::check();

Route::group(['middleware' => ['web']], function () 
{
    Route::group(['prefix'=>'merchants','middleware'=>'sentry.auth'],function()
    {
        Route::post('/{user_hash}',['as'=>'merchants.store','uses'=>'MerchantController@store']);
    });
});
cryptoBOOOOM commented 8 years ago

sorry for the late reply, but that fixed it!