vendredi 6 novembre 2015

Sentinel check if user is logged in Laravel 5.1

I have a problem with Sentinel Cartalyst. I can handle the case where a not logged user try to access. But if the session expires when a user is logged in and he try again to navigate in the website, I want to redirect him to the login page. But I saw that the code in the persistence table is not flushed as in the case of the log out.

if (Sentinel::check()) {
      return $next($request);
   }
   return redirect()->action('AuthController@login');

In the previous code I can handle only if the user exist or not.

if (Sentinel::check() && Session::get('user')) {
      return $next($request);
   }
   return redirect()->action('AuthController@login');

With this solution I can check if the session is expired or not by checking Session get user. But in the Persistence table the record remain. Is there a better solution? It could be solve with Sentinel?

Ty in advance!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire