I have one user class, which consists of two types of users and allows other users to go to different pages.
I created a filter as follows
Route::filter('isExpert', function() { $userIsExpert = 0; $userIsLoggedIn = Auth::check(); if ($userIsLoggedIn && Auth::user()->role == 'expert') { $userIsExpert = 1; } Log::info('Logged in: ' . $userIsLoggedIn . ' && Expert: ' . $userIsExpert); if ($userIsExpert == 0) { Log::info('should be logging out now.'); Auth::logout(); return Auth::basic(); } });
And such routing
Route::get('/winners', array('before' => 'isExpert', function() { $winners = DB::select('select * from winners'); return View::make('winners.index')->with('winners',$winners); }));
The idea is this: if he is not an expert, he will log out and be redirected to the login page. If so, it will just go on. However, Auth :: logout (); never logs out.
Question
Why does Auth :: logout () not work? I tried to place it anywhere in the application to no avail.
amuses
source share