module ZuoraConnect::Controllers::Helpers

def verify_with_navbar

def verify_with_navbar
  if !session[params[:app_instance_ids]].present?
    host = request.headers["HTTP_X_FORWARDED_HOST"]
    zuora_client = ZuoraAPI::Login.new(url: "https://#{host}")
    menus = zuora_client.get_full_nav(cookies.to_h)["menus"]
    app = menus.select do |item|
      matches = /(?<=.com\/services\/)(.*?)(?=\?|$)/.match(item["url"])
      if !matches.blank?
        matches[0].split("?").first == ENV["DEIS_APP"]
      end
    end
    session[params[:app_instance_ids]] = app[0]
    return app[0]
  else
    return session[params[:app_instance_ids]]
  end
end