php - laravel route on logged in not triggering -


i'm trying route index page different location if logged in though authentication system works, it's not redirecting expected i.e. getlogged, instead redirects getindex whether logged in or not.

route::filter('auth', function() {     if (!sentry::check()) return redirect::to('/'); });  route::group(array('before' => 'auth'), function() {   route::get('/', array('uses' => 'mycontroller@getlogged')); });  route::get('/', array('before' => 'detectlang', 'uses' => 'mycontroller@getindex')); 

i tested make sure auth works changing

route::group(array('before' => 'auth'), function() {   route::get('/', array('uses' => 'mycontroller@getlogged')); }); 

to

route::group(array('before' => 'auth'), function() {   route::get('/dash', array('uses' => 'mycontroller@getlogged')); }); 

and behaves can access /dash when logged in why index route not working?

you're declaring same route twice, won't work. achieve functionality, instead of adding auth filter, add guest 1 that, instead of checking if user not connected, check if is. this:

route::filter('guest', function () {     if (sentry::check()) return redirect::route('logged'); }); 

then, setup routes, along these lines:

route::get('/', array(     'as'     => 'home',     'uses'   => 'mycontroller@getindex',     'before' => 'guest' ));  route::get('/logged', array(     'as'     => 'logged',     'uses'   => 'mycontroller@getlogged',     'before' => 'auth|detectlang' )); 

note: as key gives name route, can use on redirect::route or url::route methods.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -