code: def requires_auth(f):
      @wraps(f)
      def decorated(*args, **kwargs):
          if not global_state.get_auth_settings()["active"]:
              return f(*args, **kwargs)
          if request.path in ["/login", "/logout"]:
              return f(*args, **kwargs)
          if request.path.startswith("/dtale/static"):
              return f(*args, **kwargs)
          if not session.get("logged_in") or not session.get(
              "username"
          ):
              session["next"] = request.url
              return redirect(url_for("login"))
          return f(*args, **kwargs)
  
      return decorated
  
imports: from flask import redirect, render_template, request, session, url_for
  from functools import wraps
  import dtale.global_state
label_desc: Use image node_id 3 for calling a global function with example usage: requires_auth(f) and returns: decorated, f, f, f, f, redirect