title: BadMethodCallException: Method App\Http\Controllers\UserController::getAuthenticatedUser does not exist
body: <p>When i try to Get the authenticated user data from API i get this error:
  BadMethodCallException: Method App\Http\Controllers\UserController::getAuthenticatedUser does not exist. in file D:\OpenServer\OSPanel\domains\Pumpkin\vendor\laravel\framework\src\Illuminate\Routing\Controller.php on line 68
  Please help to fix it</p>
  <p>My userController:</p>
  <pre><code>namespace App\Http\Controllers;
  
  use App\User;
  use GuzzleHttp\Psr7\Response;
  use Illuminate\Auth\Events\PasswordReset;
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Hash;
  use Illuminate\Support\Facades\Password;
  use Illuminate\Support\Facades\Validator;
  use JWTAuth;
  use Tymon\JWTAuth\Exceptions\JWTException;
  use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
  use Illuminate\Foundation\Auth\ResetsPasswords;
  
  class UserController extends Controller
  {
      public function authenticate(Request $request)
      {
          $credentials = $request-&gt;only('email', 'password');
  
          try {
              if (! $token = JWTAuth::attempt($credentials)) {
                  return response()-&gt;json(['error' =&gt; 'invalid_credentials'], 400);
              }
          } catch (JWTException $e) {
              return response()-&gt;json(['error' =&gt; 'could_not_create_token'], 500);
          }
  
          return response()-&gt;json(compact('token'));
      }
  
      public function logout()
      {
          auth()-&gt;logout();
          return response()-&gt;json(['message'=&gt;'Successfully logged out']);
      }
      protected function respondWithToken($token)
      {
          return response()-&gt;json([
              'access_token' =&gt; $token,
              'token_type' =&gt; 'bearer',
              'expires_in' =&gt; auth()-&gt;factory()-&gt;getTTL() * 60
          ]);
      }
  
      public function register(Request $request)
      {
          $validator = Validator::make($request-&gt;all(), [
              'name' =&gt; 'required|string|max:255',
              'email' =&gt; 'required|string|email|max:255|unique:users',
              'password' =&gt; 'required|string|min:6|confirmed',
          ]);
  
          if($validator-&gt;fails()){
              return response()-&gt;json($validator-&gt;errors()-&gt;toJson(), 400);
          }
  
          $user = User::create([
              'name' =&gt; $request-&gt;get('name'),
              'email' =&gt; $request-&gt;get('email'),
              'password' =&gt; Hash::make($request-&gt;get('password')),
          ]);
  
          $token = JWTAuth::fromUser($user);
  
          return response()-&gt;json(compact('user','token'),201);
      }
  
      public function getAuthenticatedUser()
      {
          try {
              if (! $user = JWTAuth::parseToken()-&gt;authenticate()) {
                  return response()-&gt;json(['user_not_found'], 404);
              }
          } catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
  
              return response()-&gt;json(['token_expired'], $e-&gt;getStatusCode());
  
          } catch (Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
  
              return response()-&gt;json(['token_invalid'], $e-&gt;getStatusCode());
  
          } catch (Tymon\JWTAuth\Exceptions\JWTException $e) {
  
              return response()-&gt;json(['token_absent'], $e-&gt;getStatusCode());
          }
          return response()-&gt;json(compact('user'));
      }
  }
  
  
  </code></pre>
  <p>My api.php</p>
  <pre><code>Route::post('auth/register', 'UserController@register');
  Route::post('auth/login', 'UserController@authenticate');
  Route::post('auth/recover', 'UserController@recover');
  Route::get('open', 'DataController@open');
  Route::post('/password/email', 'ForgotPasswordController@sendResetLinkEmail');
  Route::post('/password/reset', 'ResetPasswordController@reset');
  Route::group(['middleware' =&gt; ['jwt.verify']], function() {
      Route::get('user', 'UserController@getAuthenticatedUser');
      Route::get('closed', 'DataController@closed');
  });
  </code></pre>
  <p>Middleware:</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Middleware;
  
  use Closure;
  use JWTAuth;
  use Exception;
  use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
  
  class JwtMiddleware extends BaseMiddleware
  {
  
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          try {
              $user = JWTAuth::parseToken()-&gt;authenticate();
          } catch (Exception $e) {
              if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException){
                  return response()-&gt;json(['status' =&gt; 'Token is Invalid']);
              }else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException){
                  return response()-&gt;json(['status' =&gt; 'Token is Expired']);
              }else{
                  return response()-&gt;json(['status' =&gt; 'Authorization Token not found']);
              }
          }
          return $next($request);
      }
  }
  </code></pre>