【发布时间】:2018-11-30 10:15:18
【问题描述】:
我使用laravel-modules 创建了一个名为Article 的新模块。一些后端路由需要身份验证,我添加了auth 中间件和一个额外的权限view_backend。我正在使用https://github.com/spatie/laravel-permission 包获取角色权限。
问题是当我尝试访问路由 admin/article/posts 时,它会按预期提示我登录。但是登录后它在__construct() 方法上为Auth::user() 显示null;
我添加了web 中提到的#204 中间件,但它并没有解决问题。你能指导我解决这个问题吗?我的项目在 Laravel 5.6 上并使用最新版本的 Laravel-Modules
Route::group(['namespace' => 'Modules\Article\Http\Controllers\Backend', 'as' => 'backend.article.', 'middleware' => ['web', 'auth', 'can:view_backend'], 'prefix' => 'admin/article'], function () {
Route::resource("posts", "PostsController");
});
我的项目托管在 Github,https://github.com/nasirkhan/laravel-starter/tree/module
【问题讨论】:
标签: laravel laravel-authentication