<commit_before>module DeviseSecurityExtension::Patches
  module SessionsControllerCaptcha
    extend ActiveSupport::Concern
    included do
      define_method :create do
        if valid_captcha? params[:captcha]
          resource = warden.authenticate!(auth_options)
          set_flash_message(:notice, :signed_in) if is_navigational_format?
          sign_in(resource_name, resource)
          respond_with resource, :location => after_sign_in_path_for(resource)
        else
          flash[:alert] = t('devise.invalid_captcha') if is_navigational_format?
          respond_with({}, :location => new_session_path(resource_name))
        end
      end
    end
  end
end<commit_msg>fix for bad protected using in a devise controller<commit_after>module DeviseSecurityExtension::Patches
  module SessionsControllerCaptcha
    extend ActiveSupport::Concern
    included do
      define_method :create do
        if valid_captcha? params[:captcha]
          resource = warden.authenticate!(auth_options)
          set_flash_message(:notice, :signed_in) if is_navigational_format?
          sign_in(resource_name, resource)
          respond_with resource, :location => after_sign_in_path_for(resource)
        else
          flash[:alert] = t('devise.invalid_captcha') if is_navigational_format?
          respond_with({}, :location => new_session_path(resource_name))
        end
      end
    
      # for bad protected use in controller
      define_method :auth_options do
        { :scope => resource_name, :recall => "#{controller_path}#new" }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07667934093789606, 'fraction_numerical': 0.0, 'mean_word_length': 3.256064690026954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3835736', 'n_tokens_mistral': 452, 'n_tokens_neox': 438, 'n_words': 99}