【问题标题】:Chatter doesn't recognize Auth::user in Laravel 5.4Chatter 无法识别 Laravel 5.4 中的 Auth::user
【发布时间】:2018-03-07 12:53:51
【问题描述】:

Hell0,我在安装过程中没有任何错误和一切(使用此说明):

https://github.com/thedevdojo/chatter

顺利通过,0 个错误,一切看起来都很好,但是当我登录时它无法识别我的用户。

dd(Auth::user());返回假。

如果我在视图和控制器中使用“Auth::guard('webfront')->user()”而不是“Auth::user()”,它将获取会话并向我显示要发布的表单。但是当我尝试发帖时,它会将我重定向回登录页面(当我仍然登录时)。

只有一件事困扰着我……主要的系统控制器在:

“App\Http\Controllers\Frontend...”和“App\Http\Controllers\Frontend\Auth”

视图的文件夹名称也相同。起初,当我尝试强制“使用身份验证”时使用“App\Http\Controllers\Frontend\Auth;”但它返回的是找不到类“App\Http\Controllers\Frontend\Auth”

有人遇到过这个问题吗?有什么解决办法吗?谢谢:-)

【问题讨论】:

    标签: php laravel authentication laravel-5.4


    【解决方案1】:

    已修复:适用于遇到相同问题的所有人。您必须编辑 chatter.php 配置文件,并将您使用的中间件的 id 添加到它们的字段中,例如:

    'middleware' => [
        'global'     => ['web'],
        'home'       => [],
        'discussion' => [
            'index'   => [],
            'show'    => [],
            'create'  => ['auth:webfront'],
            'store'   => ['auth:webfront'],
            'destroy' => ['auth:webfront'],
            'edit'    => ['auth:webfront'],
            'update'  => ['auth:webfront'],
        ],
        'post' => [
            'index'   => [],
            'show'    => [],
            'create'  => ['auth:webfront'],
            'store'   => ['auth:webfront'],
            'destroy' => ['auth:webfront'],
            'edit'    => ['auth:webfront'],
            'update'  => ['auth:webfront'],
        ],
        'category' => [
            'show' => [],
        ],
    ],
    

    【讨论】:

      猜你喜欢
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多