<commit_before>require "action_controller/metal"

module Devise
  # Failure application that will be called every time :warden is thrown from
  # any strategy or hook. Responsible for redirect the user to the sign in
  # page based on current scope and mapping. If no scope is given, redirect
  # to the default_url.
  class FailureApp < ActionController::Metal
    include ActionController::RackDelegation
    include ActionController::UrlFor
    include ActionController::Redirecting

    mattr_accessor :default_message
    self.default_message = :unauthenticated

    def self.call(env)
      action(:respond).call(env)
    end

    def self.default_url_options(*args)
      ApplicationController.default_url_options(*args)
    end

    def respond
      scope = env['warden.options'][:scope]
      store_location!(scope)
      redirect_to send(:"new_#{scope}_session_path", query_string_params)
    end

  protected

    # Build the proper query string based on the given message.
    def query_string_params
      message = warden.try(:message) || warden_options[:message] || self.class.default_message

      case message<commit_msg>Use available warden_options method instead of env.<commit_after>require "action_controller/metal"

module Devise
  # Failure application that will be called every time :warden is thrown from
  # any strategy or hook. Responsible for redirect the user to the sign in
  # page based on current scope and mapping. If no scope is given, redirect
  # to the default_url.
  class FailureApp < ActionController::Metal
    include ActionController::RackDelegation
    include ActionController::UrlFor
    include ActionController::Redirecting

    mattr_accessor :default_message
    self.default_message = :unauthenticated

    def self.call(env)
      action(:respond).call(env)
    end

    def self.default_url_options(*args)
      ApplicationController.default_url_options(*args)
    end

    def respond
      scope = warden_options[:scope]
      store_location!(scope)
      redirect_to send(:"new_#{scope}_session_path", query_string_params)
    end

  protected

    # Build the proper query string based on the given message.
    def query_string_params
      message = warden.try(:message) || warden_options[:message] || self.class.default_message

      case message
{'fraction_non_alphanumeric': 0.06923409779316313, 'fraction_numerical': 0.0, 'mean_word_length': 3.908704883227176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6927461', 'n_tokens_mistral': 637, 'n_tokens_neox': 614, 'n_words': 193}