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

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

c# - Avoiding duplicate methods for Task and Task<T> -

javascript - Which segment of a polyline was clicked? -