code: def login_required(func) -> functools.wraps:
      @functools.wraps(func)
      async def wrapper(request: Request, *args, **kwargs):
          token, u = get_app_token(request)
  
          kwargs["token"] = token
          if u is None:
              error_end = (
                  "view this content"
                  if request.method == "GET"
                  else "perform this action"
              )
              response = JSONResponse(
                  {
                      "data": {
                          "error": f"You need to be authorized to {error_end}"
                      },
                      "meta": {},
                  }
              )
              response.status_code = 403
  
              return response
  
          if inspect.iscoroutinefunction(func):
              res = await func(request, *args, **kwargs)
          else:
              res = func(request, *args, **kwargs)
  
          if isinstance(res, tuple):
              res, res_code = res
          else:
              res_code = 200 if res else 404
  
          if res.get("token"):
              token = res["token"]
  
          response = JSONResponse(res)
  
          response.headers["Authorization"] = f"{token}"
          response.status_code = res_code
  
          return response
  
      return wrapper
  
file_path: labml/app/server/labml_app/auth/__init__.py
imports: import functools
  import inspect
  from typing import Optional
  from fastapi import Request
  from fastapi.responses import JSONResponse
  from ..db import project
  from ..db import user
  from ..db.user import User
label_desc: Use image node_id 2 for calling a global function with example usage: login_required(func) and returns: wrapper, response, response