<commit_before>class Devise::CheckgaController < Devise::SessionsController
  prepend_before_filter :devise_resource, :only => [:show]
  prepend_before_filter :require_no_authentication, :only => [ :show, :update ]

  include Devise::Controllers::Helpers

  def show
    @tmpid = params[:id]
    if @tmpid.nil?
      redirect_to :root
    else
      render :show
    end
  end

  def update
    resource = resource_class.find_by_gauth_tmp(params[resource_name]['tmpid'])

    if not resource.nil?
      if resource.validate_token(params[resource_name]['gauth_token'].to_i)
        set_flash_message(:notice, :signed_in) if is_navigational_format?
        sign_in(resource_name,resource)
        warden.manager._run_callbacks(:after_set_user, resource, warden, {:event => :authentication})
        respond_with resource, :location => after_sign_in_path_for(resource)

        if not resource.class.ga_remembertime.nil? 
          cookies.signed[:gauth] = {
            :value => resource.first_authentication_key << "," << Time.now.to_i.to_s,
            :secure => !(Rails.env.test? || Rails.env.development?),
            :expires => (resource.class.ga_remembertime + 1.days).from_now
          }
        end
      else
        set_flash_message(:error, :error)
        redirect_to after_sign_in_error_path_for(resource)
      end

    else
      set_flash_message(:error, :error)
      redirect_to after_sign_in_error_path_for(resource)
    end
  end

  private

  def devise_resource
    self.resource = resource_class.new
  end
end<commit_msg>use cached route<commit_after>class Devise::CheckgaController < Devise::SessionsController
  prepend_before_filter :devise_resource, :only => [:show]
  prepend_before_filter :require_no_authentication, :only => [ :show, :update ]

  include Devise::Controllers::Helpers

  def show
    @tmpid = params[:id]
    if @tmpid.nil?
      redirect_to :root
    else
      render :show
    end
  end

  def update
    resource = resource_class.find_by_gauth_tmp(params[resource_name]['tmpid'])

    if not resource.nil?
      if resource.validate_token(params[resource_name]['gauth_token'].to_i)
        set_flash_message(:notice, :signed_in) if is_navigational_format?
        sign_in(resource_name,resource)
        warden.manager._run_callbacks(:after_set_user, resource, warden, {:event => :authentication})
        respond_with resource, :location => session[:cached_redirect_path] || after_sign_in_path_for(resource)

        if not resource.class.ga_remembertime.nil? 
          cookies.signed[:gauth] = {
            :value => resource.first_authentication_key << "," << Time.now.to_i.to_s,
            :secure => !(Rails.env.test? || Rails.env.development?),
            :expires => (resource.class.ga_remembertime + 1.days).from_now
          }
        end
      else
        set_flash_message(:error, :error)
        redirect_to after_sign_in_error_path_for(resource)
      end

    else
      set_flash_message(:error, :error)
      redirect_to after_sign_in_error_path_for(resource)
    end
  end

  private

  def devise_resource
    self.resource = resource_class.new
  end
end
{'fraction_non_alphanumeric': 0.10316192909613542, 'fraction_numerical': 0.0006387735547748323, 'mean_word_length': 3.3682008368200838, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '242809', 'n_tokens_mistral': 1006, 'n_tokens_neox': 981, 'n_words': 170}