我对 laravel 中内置的用户身份验证功能有疑问。 我的身份验证部分可以正常工作,但 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
}
});
这是我的管理页面。当我在用户成功通过身份验证后重定向到此页面时出现无限循环。
Route::get('admin', array('before' => 'auth', 'do' => function(){
return "you are logged in! " . HTML::link('logout', 'logout dude');
}));
你认为这里有什么问题?
最佳答案
正如 Dayle Rees 在其博客中所说:
Please remember not to apply the auth filter to your login URI, you will experience a terrible loop!
按照本教程进行操作,一切都应该是甜蜜的:) http://daylerees.com/2012/04/07/laravel-authentication/
关于php - laravel 中的用户认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13446956/