Php beforeFilter('auth')上的身份验证laravel 4不工作

Php beforeFilter('auth')上的身份验证laravel 4不工作,php,authentication,laravel-4,laravel-routing,before-filter,Php,Authentication,Laravel 4,Laravel Routing,Before Filter,我有一些控制器,我想从登录页面保护它,我添加登录页面 我在我的控制器上添加了_u结构来保护它 请参阅我的代码: 在NewsController中,我需要来自身份验证的安全getindex页面 class NewsController extends Basecontroller{ public function __construct() { $this->beforeFilter('csrf', array('on'=>'post')); $this->

我有一些控制器,我想从登录页面保护它,我添加登录页面 我在我的控制器上添加了_u结构来保护它

请参阅我的代码:

在NewsController中,我需要来自身份验证的安全getindex页面

class NewsController extends Basecontroller{

    public function __construct() {
   $this->beforeFilter('csrf', array('on'=>'post'));
   $this->beforeFilter('auth');
}
在路由文件中,我添加了以下代码:

Route::post('login',function()
{

 //print_r(Hash::make(Input::get('UserName')));

 if (Auth::attempt(array('UserName'=>Input::get('UserName'), 'password'=>Input::get('Password')))) {
  return Redirect::to('news')->with('message', 'You are now logged in!');
  } else {
  return Redirect::to('login')
    ->with('message', 'Your username/password combination was incorrect')
    ->withInput();
}
我确信用户通行证是正确的,并且已通过,但在控制器中,请在登录页面中重定向我

怎么了

我的完整route.php文件

Route::get('login',function(){
 return View::make('Admin/Login');

 });
Route::post('login',function()
{


if (Auth::attempt(array('UserName'=>Input::get('UserName'),     'password'=>Input::get('Password')))) {
    return Redirect::to('news')->with('message', 'You are now logged in!');
} else {
return Redirect::to('login')
    ->with('message', 'Your username/password combination was incorrect')
    ->withInput();
}

});


Route::controller('news', 'NewsController');
Route::controller('article', 'ArticleController');
Route::controller('albume', 'AlbumeController');
Route::controller('staticcontent', 'StaticContentController');
Route::controller('links', 'LinksController');
Route::controller('faq', 'FAQController');
Route::controller('employment', 'EmploymentController');
Route::controller('poll', 'PollController');
Route::controller('branches', 'BranchesController');
Route::controller('user', 'UserController');
Route::controller('access', 'AccessLevelController');
Route::controller('metatag', 'MetaTagController');
Route::controller('product', 'ProductController');
并获取登录视图:

{{Form::open(array('method'=>'post','id'=>'Filter'))}}
<table class="Login">
<tr>
<td>user</td>
<td>{{Form::text('UserName')}}</td>
</tr>
<tr>
<td>pass</td>
<td>{{Form::password('Password')}}</td>
</tr>
<tr>
<td colspan="2">{{HTML::link('','forget pass ?')}}</td>
</tr>
<tr>
<td colspan="2">{{Form::submit('login')}}</td>
</tr>
</table>
{{Form::close()}}
我找到了答案

我想将用户表ID添加到Model user.php中

protected $primaryKey = "ID";

在您的登录和新闻路线中发布routes.php文件的其余部分?特别是重定向::到'news'和重定向::到'login'的位置。你是什么意思?我不明白什么是rest?你能把你完整的路由文件贴出来吗?还有可能是您的登录视图。好的,我编辑了我的帖子,添加了我的路由文件和登录视图。您的表单::open没有url、路由或操作?