1
votes

I have installed authentication using

php artisan make:auth

Before and after loggingin menu shows login and Register link appears even user has logged in. I checked the code below and I found it was correct, there may be problem in Auth::guest(). check the code below

@if (Auth::guest())
                        <li><a href="{{ url('/login') }}">Login</a></li>
                        <li><a href="{{ url('/register') }}">Register</a></li>
                    @else

enter image description here

I referred some of the questions and they have given some dirty fix. example below.

Route::group(['middleware' => ['web']], function () {
    Route::get('/', 'HomeController@index');
});

Actually what this fix does,is force user to login by showing login page.Actually when the user logged in it should hide and show the user name. When I click on home link, it hides and shows username.

1
so even when you sign in successfully it would never show you that the user has logged in ?Yehia Awad
when I click home link it shows I'm logged in. 'localhost:8000/' this does't shows only login Register option in the nav barVrangle
var_dump(Session::all()); what does it give you?Yehia Awad

1 Answers

2
votes

Make sure you have the view on the web middleware, use the following code.

Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/', function () { return view('welcome'); });
Route::get('/home', 'HomeController@index');
});