redirect - Laravel 4 authentication login issue -


in laravel login route, have following code:

route::get('/login', function() {     $credentials = input::only('username', 'password');     if (auth::attempt($credentials)) {         return redirect::intended('/');     }     return redirect::to('login'); }); 

when try access /login, "web page has redirect loop" error. how fix this?

tia - joe

take @ logic, if user has invalid credentials redirected /login try validate credentials again causing infinite loop. should split /login post , route prevent this. in view when submit login form, should sent post.

route::get('/login', function() {    //do nothing here, return view login form });  route::post('/login', function() {     $credentials = input::only('username', 'password');     if (auth::attempt($credentials)) {         return redirect::intended('/');     }     return redirect::to('login'); }); 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -