Chatter doesn't recognize Auth::user in Laravel 5.4

nikolay-dimitrov

Sep 26th, 2017 09:14 AM

Hello, i don't have any errors and everything during installation (using this instructions): https://github.com/thedevdojo/chatter passed well with 0 errors, everything looks fine, but it dose't recognize my user when i'm logged in. dd(Auth::user()); returns false. If I'm using "Auth::guard('webfront')->user()" instead "Auth::user()" in the views & controllers it's getting the session and shows me the form to post. But than when i try to post, it's redirecting me back to login page (while i'm still logged in).

There is just one thing that is bothering me... The main system controllers are in: "App\Http\Controllers\Frontend..." and "App\Http\Controllers\Frontend\Auth" and the same folder names for the views too. At first when i try to force "use Auth;" to use "App\Http\Controllers\Frontend\Auth;" but than it return's that can't find the class "App\Http\Controllers\Frontend\Auth"

Does anybody had this problem? Any solution? Thanks :-)

mark

Sep 26th, 2017 09:33 AM

Chatter currently uses the default authentication gate and only supports that. We are however open for a pull request for this.

nikolay-dimitrov

Sep 26th, 2017 10:30 AM

Any sugestions where should i touch?

mark

Sep 26th, 2017 10:43 AM

My idea would be allow to set the authentication guard in the configuration. Then whenever the Auth:: facade is used, it should simply use Auth::guard($guard)-> instead in order to use the configured authentication guard. I believe this have to be done in the controllers and might be in some views as well.

nikolay-dimitrov

Sep 27th, 2017 08:22 AM

UPDATE: Everything was in the config file... For those who have the same problem, just you have to add the id of your middleware into the chatter.php config file like:

'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' => [], ], ],