protected function unauthenticated($request, AuthenticationException $e)
    {
        return $request->expectsJson()
            ? response()->json(['message' => $e->getMessage()], 401)
            : redirect()->guest($e->redirectTo() ?? route('login'));
    }