Protecting all admin/ routes with auth in Laravel

前端 未结 3 1155

I am brand new to laravel and am setting up admin panel authorization on my first application. The way I have my files setup currently setup is:

controllers/
             


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 01:33

    In your admin/login route you have an unnecessary return before the Auth::logout() call, nuke that and it should fix it up.

    Another issue here is that only your one 'admin' route is getting filtered. You could wrap all of your admin routes with a Route::group() and apply the 'auth' before filter or you could use Route::filter('pattern: admin/*', 'auth') too.

    Check out:

    http://laravel.com/docs/routing#filters

    For the second issue, is your Admin Dashboard controller class named Admin_Dashboard_Controller and if so, do you have an action_index() or get_index() function in there returning a view?

    Check out:

    http://laravel.com/docs/controllers#nested-controllers

    (I'm assuming you're using L3 here btw.)

提交回复
热议问题