In order to see a different page, I usually use a route like this.
Route::get('/',function(){
if(Auth::guest()){
return View::make('login');
}
return View::make('my_page');
});
Hum...like @moinescumihai said, you should do the Route way, your way is kind off defeating the purpose of MVC architecture.
Yes, you both are right, but here I want to handle back button scenario after login. The problem is that I have tried the following : Inside Controller
public function create() {
if(!(Auth::guest())){
return Redirect::intended('/');
}else{
return View::make('sessions.create');
}
}
Its working fine. But after login if i click back button in browser it returns back to Login Form. Its really looking bad. Using :
header('location : somelocation.php');
I can achieve that but I want to use Laravel feature if any.
In my understanding, your problem is like this:
You have a login page and want it displayed only if the user is not logged in. You can achieve that using the code I gave you
But, to my knowledge, the back button in your browser will redirect you to the same page, with the same content. It's independent from your app.
As you said, using header('location : somelocation.php'); you "tricked" it
You can also do the same trick using laravel
Lets' say your login/post login page = 'testing'
Try using this:
Route::get('/,',function(){
return Redirect::to('testing');
});
Route::get('testing',function(){
if(Auth::guest()){
return View::make('login');
}
return View::make('my_page');
});
It's not pleasant but I guess will do the trick. In my opinion you should just stick to
Route::get('/',function(){
if(Auth::guest()){
return View::make('login');
}
return View::make('my_page');
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community