Authentication redirects fail
<p>when I login with wrong credentials I got the right response.
when I login with the right credentials the login page reload with 302 request
but it never redirect to statistics page.
when I debug it I found that the code goes to this authinticate.php in the middleware folder, 
it redirect to the guest login state</p>

<pre><code>if (Auth::guard($guard)-&gt;guest()) {
            if ($request-&gt;ajax() || $request-&gt;wantsJson()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()-&gt;guest('login');
            }
        }
</code></pre>

<p><strong>see the code:-</strong></p>

<p><strong>Route.php</strong></p>

<pre><code>Route::get('login', 'LoginController@index');
Route::post('signin', 'LoginController@signin');
Route::get('signout', 'LoginController@signout');


Route::group(['prefix' =&gt; 'api'], function() {
    Route::resource('authenticate', 'AuthenticateController', ['only' =&gt; ['index']]);
    Route::post('authenticate', 'AuthenticateController@authenticate');
});

Route::group(['middleware' =&gt; ['web']], function () {
    Route::auth();
    Route::get('/', 'StatisticsController@index');
    Route::get('/statistics', 'StatisticsController@statistics');

});
</code></pre>

<p><strong>Login Controller</strong></p>

<pre><code>    public function index() {

        return view('login');
    }

    public function signin(Request $request) {

        $errors = [];
        $email=$request['email'];
        $password= $request['password'];
        $credentials = array('email' =&gt; $email, 'password' =&gt; $password);

        if(Auth::attempt($credentials))
        {
          return redirect('/statistics');


        }
        return "bad request";

    }
     public function signout()
    {
        Auth::logout();
        return redirect('/login');    }

}
</code></pre>

<p><strong>Statistics Controller</strong></p>

<pre><code>class StatisticsController extends Controller {
    public function __construct()
    {
                    $this-&gt;middleware('auth');

    }
    public function index() {

    return view('statistics')-&gt;with($data);
  }

public function statistics() {
        return view('statistics');

  }



}
</code></pre>

<p><strong>Kernal.php</strong> note that there is JWT auth library I use it for restful authentication with the mobile app only.</p>

<pre><code>protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    ];

    protected $middlewareGroups = [
        'web' =&gt; [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
        ],

        'api' =&gt; [
            'throttle:60,1',
        ],
    ];

    protected $routeMiddleware = [
        'auth' =&gt; \App\Http\Middleware\Authenticate::class,
        'auth.basic' =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'jwt.auth' =&gt; 'Tymon\JWTAuth\Middleware\GetUserFromToken',
        'jwt.refresh' =&gt; 'Tymon\JWTAuth\Middleware\RefreshToken'
    ];
</code></pre>

<p><strong>middleware/authenticate.php</strong></p>

<pre><code>&lt;?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class Authenticate
{

    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)-&gt;guest()) {
            if ($request-&gt;ajax() || $request-&gt;wantsJson()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()-&gt;guest('login');
            }
        }

        return $next($request);
    }
}
</code></pre>