使用 Entrust Package 忽略在 Laravel 5 中进行访问检查的路由

Ignore a route for access checking in Laravel 5 using Entrust Package

我正在使用 Entrust Laravel 软件包,它工作正常,但有一个问题。

我想使用以下控制器向管理员显示登录表单

Route::get('/admin/login', array('as' => 'admin_login', 'uses' => 'Admin\AdminAccessController@getLogin'));

如何告诉 Entrust 'disable' 某些路由的访问控制,例如 "admin/login"?

Entrust::routeNeedsRole('admin/*', 'owner',dd(
    "Access Denied!"
));

你可以这样做.. (Documentation)

Route::filter('admin', function()
{
    // check the current user
    if (!Entrust::hasRole('admin')) {
        App::abort(403);
    }
});

// only admin will have access to routes within admin/login
Route::when('admin/login', 'admin');