<commit_before># frozen_string_literal: true

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_action :force_https
  before_action :capture_campaign_params
  before_action :authenticate, except: :update_billing

  helper_method :current_user, :signed_in?, :masquerading?

  def update_billing
    render layout: false
  end

  protected

  def verified_request?
    super || valid_authenticity_token?(session, request.headers["X-XSRF-TOKEN"])
  end

  private

  def force_https
    if Hound::HTTPS_ENABLED && !request.ssl? && force_https?
      redirect_to protocol: "https://", status: :moved_permanently
    end
  end

  def force_https?
    true
  end

  def capture_campaign_params
    session[:campaign_params] ||= {
      utm_campaign: params[:utm_campaign],
      utm_medium: params[:utm_medium],
      utm_source: params[:utm_source],
    }
  end

  def authenticate
    unless signed_in?
      redirect_to root_path<commit_msg>Save Google click IDs with session (#1759)<commit_after># frozen_string_literal: true

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_action :force_https
  before_action :capture_campaign_params
  before_action :authenticate, except: :update_billing

  helper_method :current_user, :signed_in?, :masquerading?

  def update_billing
    render layout: false
  end

  protected

  def verified_request?
    super || valid_authenticity_token?(session, request.headers["X-XSRF-TOKEN"])
  end

  private

  def force_https
    if Hound::HTTPS_ENABLED && !request.ssl? && force_https?
      redirect_to protocol: "https://", status: :moved_permanently
    end
  end

  def force_https?
    true
  end

  def capture_campaign_params
    session[:campaign_params] ||= {
      utm_campaign: params[:utm_campaign],
      utm_medium: params[:utm_medium],
      utm_source: params[:utm_source],
      gclid: params[:gclid],
    }
  end

  def authenticate
    unless signed_in?
      redirect_to root_path
{'fraction_non_alphanumeric': 0.08374875373878365, 'fraction_numerical': 0.0019940179461615153, 'mean_word_length': 4.159383033419023, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6189416', 'n_tokens_mistral': 662, 'n_tokens_neox': 628, 'n_words': 139}