I do not want to show login page after login in laravel 4. If a logged in user want to visit login page it should redirect to homepage('/'). I am using Sentry for authentication.
filter.php
Route::filter(
'auth', function () {
if (!Sentry::check()) {
return Redirect::to('login');
}
}
routes.php
Route::get('login', array('as' => 'login', function() {
return View::make('login');
}))->before('guest');
Route::post('login', 'AuthController@postLogin');
AuthController.php
function postLogin() {
try {
// Set login credentials
$credentials = array(
'email' => Input::get('email'), 'password' => Input::get('password')
);
// Try to authenticate the user
$user = Sentry::authenticate($credentials, false);
if ($user) {
return Redirect::to('/');
}
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
return Redirect::to('login')->withErrors('Login field is required');
}
}
After successful login if, if login page is requested it still shows the login page