php - Laravel 5.1 Sentinel::getUser() return null -


i using sentinel authenticate users , auth middleware.

middleware code:

public function handle($request, closure $next) {     var_dump(sentinel::guest()); // prints false     if (sentinel::guest()) {         if ($request->ajax()) {             return response('unauthorized.', 401);         } else {             return redirect()->guest('/login');         }     }      return $next($request); } 

controller code:

public function getaccount() {     var_dump(sentinel::guest()); // prints true     return sentinel::getuser(); } 

routes.php

route::group(['middleware' => ['auth']], function () {     route::get('api/v1/temp/users/account', 'app\http\controllers\userscontroller@getaccount'); } 

then if browse api/v1/temp/users/account var_dump() in middleware printing false, while var_dump() inside controller printing true seems nonsense.

what's wrong?

it turned out using native facade instead of laravel facade cartalyst\sentinel\laravel\facades\sentinel. fixed.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -