I have a question about the built in user authentication functionality in laravel.
I got the authentication part to work but it doesn’t seem like a user is stored in the session.
Route::get('login', function(){
$username = 'stardriver';
$password = '1234';
$creds = array('username' => $username, 'password' => $password);
if(Auth::attempt($creds)){ //I assume that its already logged in when it goes here
return Auth::guest(); //but why does this return 1?
}else{
return 'nope wrong creds'; //if I change the username or password declared above, it goes here
}
});
Here’s my admin page. I get an infinite loop when I redirect to this page after the user has successfully authenticated.
Route::get('admin', array('before' => 'auth', 'do' => function(){
return "you are logged in! " . HTML::link('logout', 'logout dude');
}));
What do you think is wrong here?
As Dayle Rees said on its blog :
Follow this tutorial, and everything should be sweet 🙂
http://daylerees.com/2012/04/07/laravel-authentication/