title: jwt auth doesn't work for other controllers in Laravel?
body: <p>Laravel web auth was working well.
  I'm trying to use jwt-auth module.
  Here's my code with jwt-auth module</p>
  <pre><code>---authcontroller.php
      public function login(Request $request)
      {
          $validator = Validator::make($request-&gt;all(), [
              'email' =&gt; 'required|email',
              'password' =&gt; 'required|string|min:6',
          ]);
  
          if ($validator-&gt;fails()) {
              // return response()-&gt;json($validator-&gt;errors(), 200);
              session()-&gt;flash('error', json_encode($validator-&gt;errors()));
              return back()-&gt;withInput();
          }
          if (!$token = auth()-&gt;attempt($validator-&gt;validated())) {
              // return response()-&gt;json(['error' =&gt; 'Unauthorized'], 200);
              session()-&gt;flash('error', 'These credentials do not match.');
              return back()-&gt;withInput();
          }
          //////// this is test code
          echo auth()-&gt;check();
          //////////////////
          $response_token = $this-&gt;createNewToken($token);
          session()-&gt;flash('token', $response_token);
          return Redirect::to('/');
      }
  
  ---web.php
  
  Route::group([
      'middleware' =&gt; 'api',
      'prefix' =&gt; 'auth'
  
  ],
      function ($router) {
          Route::post('/login', [AuthController::class, 'login']);
          Route::post('/register', [AuthController::class, 'register']);
          Route::post('/logout', [AuthController::class, 'logout']);
          Route::post('/refresh', [AuthController::class, 'refresh']);
          Route::get('/user-profile', [AuthController::class, 'userProfile']);
      }
  );
  ---auth.php
  
      'defaults' =&gt; [
          'guard' =&gt; 'api',
          'passwords' =&gt; 'users',
      ],
  
  
      'guards' =&gt; [
          'web' =&gt; [
              'driver' =&gt; 'session',
              'provider' =&gt; 'users',
          ],
  
          'api' =&gt; [
              'driver' =&gt; 'jwt',
              'provider' =&gt; 'users',
              'hash' =&gt; false,
          ],
      ],
  </code></pre>
  <p>The problem is *test code returns true, but in the redirection controller, auth()-&gt;check() returns false.
  i.e. auth()-&gt;check() returns true only when login controller, but returns false for other controllers</p>
  <p>What's the problem?</p>
  <p>---updates (redirection page code)</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;{{ str_replace('_', '-', app()-&gt;getLocale()) }}&quot;&gt;
      &lt;head&gt;
          &lt;meta charset=&quot;utf-8&quot;&gt;
          &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
          &lt;meta name=&quot;csrf-token&quot; content=&quot;{{ csrf_token() }}&quot;&gt;
  
          &lt;title&gt;@yield('title')&lt;/title&gt;
  
          &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css&quot;&gt;
  
          &lt;!-- Fonts --&gt;
          &lt;link href=&quot;https://fonts.googleapis.com/css?family=Nunito:400,600,700&quot; rel=&quot;stylesheet&quot;&gt;
  
          &lt;!-- Styles --&gt;
          &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css&quot; integrity=&quot;sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==&quot; crossorigin=&quot;anonymous&quot; /&gt;
  
  
  
          &lt;!-- Scripts --&gt;
          &lt;script src=&quot;https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.0/dist/alpine.js&quot; defer&gt;&lt;/script&gt;
          &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
          &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
          @yield('extra-css')
          &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ asset('css/style.css') }}&quot;&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;header&gt;
              &lt;div class=&quot;logo&quot;&gt;
                  &lt;a href=&quot;/&quot;&gt;
                      &lt;img src=&quot;{{ asset('images/blue-logo.png')}}&quot;/&gt;
                  &lt;/a&gt;
              &lt;/div&gt;
              &lt;div class=&quot;navigation&quot;&gt;
                  &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('audition') }}&quot;&gt;Audition&lt;/a&gt;
                  &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('about') }}&quot;&gt;About&lt;/a&gt;
                  &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('playing') }}&quot;&gt;Playing&lt;/a&gt;
                  &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('faq') }}&quot;&gt;Faq&lt;/a&gt;
                  @if(!auth('api')-&gt;check())
                      &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('login') }}&quot;&gt;Login&lt;/a&gt;
                      &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('userType') }}&quot;&gt;Register&lt;/a&gt;
                  @else
                      &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('support') }}&quot;&gt;Support&lt;/a&gt;
                      &lt;a class=&quot;mr-3&quot; href=&quot;{{ route('dashboard') }}&quot;&gt;{{ Auth::user()-&gt;name }}&lt;/a&gt;
                      &lt;form class=&quot;d-inline-block&quot; method=&quot;POST&quot; action=&quot;{{ route('logout') }}&quot;&gt;
                          @csrf
                          &lt;a class=&quot;mr-3&quot; href=&quot;#&quot; onclick=&quot;event.preventDefault(); this.closest('form').submit();&quot;&gt;Logout&lt;/a&gt;
                      &lt;/form&gt;
                  @endif
              &lt;/div&gt;
          &lt;/header&gt;
          @yield('content')
          &lt;footer id=&quot;footer&quot;&gt;
              &lt;ul class=&quot;icons&quot;&gt;
                  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;icon brands fa-twitter&quot;&gt;&lt;span class=&quot;label&quot;&gt;Twitter&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;icon brands fa-instagram&quot;&gt;&lt;span class=&quot;label&quot;&gt;Instagram&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;icon brands fa-github&quot;&gt;&lt;span class=&quot;label&quot;&gt;GitHub&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;icon fa-envelope&quot;&gt;&lt;span class=&quot;label&quot;&gt;Email&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
              &lt;ul class=&quot;copyright&quot;&gt;
                  &lt;li&gt;&amp;copy; Untitled.&lt;/li&gt;&lt;li&gt;Credits: &lt;a href=&quot;http://html5up.net&quot;&gt;HTML5 UP&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/footer&gt;
          @yield('extra-js')
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>