Mar 7, 2017
0
Level 2
Destroying session
Is there a way to destroy a session when logging out of a logged in section. I've done this
public function doLogout(){
//Allows the user to log out
Auth::logout();
return redirect()->route('login');
}
But I'm still able to go to the logged in page through the url.
Here is my routes
Route::group(['middleware' => ['accountActivated']], function()
{
Route::get('/dashboard/home', [
'uses' => 'AuthorsController@dashboard',
'as' => 'dashboard'
]);
Route::resource('dashboard/stories', 'StoryController');
Route::resource('dashboard/clients', 'clientsController');
Route::get('dashboard/logout', [
'uses' => 'AuthorsController@doLogout',
'as' => 'logout'
]);
});
and this is my middleware called AccountActivated.php
public function handle($request, Closure $next, $guard = 'authors_admin')
{
if(!Auth::guard($guard)->check()){
return redirect()->to('login')->with('success', 'Denied was a success');
}
return $next($request);
}
Please or to participate in this conversation.