Esempio n. 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     abort_unauthorized($id);
     $user = User::with('sessions')->findOrFail($id);
     $user->currentSessionHash = \App\ValidSession::generateFingerprint(request())['hash'];
     return $user;
 }
Esempio n. 2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!Auth::check()) {
         return $next($request);
     }
     $fingerprint = ValidSession::generateFingerprint($request);
     $session = ValidSession::findSession($fingerprint, !$request->is('ajax/archive/stats'));
     if (!$session) {
         Auth::logout();
     } elseif (!Auth::check()) {
         $session->delete();
     }
     return $next($request);
 }
Esempio n. 3
0
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     $events->listen('auth.login', function ($user, $remember) {
         $fingerprint = ValidSession::generateFingerprint(request());
         ValidSession::makeSession($fingerprint);
     });
     $events->listen('auth.logout', function ($user) {
         $fingerprint = ValidSession::generateFingerprint(request());
         $session = ValidSession::findSession($fingerprint);
         if ($session) {
             $session->delete();
         }
     });
 }