doupi3874 2014-11-10 03:19
浏览 99
已采纳

Laravel 5 Auth Filter不起作用

I just tried Laravel 5 after a time at 4.2.. The docs says it is possible to use 'before' => 'auth' as always, but for me it does not work.

I have no idea whats wrong, I have read the docs, search on internet but seems not to find anything. My code looks as:

$router->group(['before' => 'auth'], function($router)
{

     // 
     $router->get('admin', function()
     {
          return View::make('admin.index');
     });

     //
     $router->get('login', function()
     {
          return View::make('admin.login');
     });

});

Anyone can see what I doing wrong here?

  • 写回答

1条回答 默认 最新

  • dsgdsf12312 2014-11-10 07:32
    关注

    In laravel5 filters are removed. Instead you can use middleware classes which are more clean.

    In this blog you can read more about the middleware classes and that they're a replacement of filters.

    If you want to do it with self written routes you can use this:

    Route::group(['middleware' => 'auth'], function()
    {
    
         Route::get('admin', function()
         {
              return View::make('admin.index');
         });
    
         Route::->get('login', function()
         {
              return View::make('admin.login');
         });
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 表达式必须是可修改的左值
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题