jeudi 31 décembre 2015

Laravel 5.2 Auth not Working

As you guys know Laravel 5.2 was released a few days ago. I am trying this new version. I made a new project using the following command on CLI:

laravel new testapp

As per documentation of Authentication Quickstart, I followed the following command to scaffold routes and views of authentication:

php artisan make:auth

It worked fine. Registration is working fine. But I am facing problem in Login. After login I tested following in route.php file:

   Route::get('/', function () {
    dd( Auth::user());
    return view('welcome');
});

Auth::user() is returning null and also Auth::check() and Auth::guest() are not working appropriately. I have tried same thing again and again two three times by making new projects but couldn't get the correct results.

Below is the complete route.php.

    <?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    dd( Auth::());
    return view('welcome');
});

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

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

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'HomeController@index');
});

Can anyone help me? or Is anyone facing the same problem? How can I fix it?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Ts1sW7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire