<commit_before># Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  secret_path = File.join(RAILS_ROOT, "config/secret.txt")
  if File.exist?(secret_path)
    secret = open(secret_path) { |io| io.read }.gsub(/\s/, '')
  end
  if secret.empty?
    characters = ("0".."9").to_a + ("a".."f").to_a
    secret = Array.new(128) { characters[rand(characters.size)] }.join
    open(secret_path, "w") { |io| io.write(secret) }
  end

  protect_from_forgery :secret => secret
  
  # See ActionController::Base for details 
  # Uncomment this to filter the contents of submitted sensitive data parameters
  # from your application log (in this case, all fields with names like "password"). 
  # filter_parameter_logging :password
  
  I18n.default_locale = "ja"

  private
  def authorize
    unless session[:user_id] && (same_user = (session[:user_id].id == User.find(params["user"]).id))
      logger.debug "DEBUG(authorize) : session = <#{(session[:user_id]&&session[:user_id].to_yaml)}>, user = <#{User.find(params["id"] || params["user"]).to_yaml}>"
      flash[:notice] = t("permission_denied", :scope => %w(notice)) unless same_user
      flash[:notice] = t("please_log_in", :scope => %w(notice)) if same_user
      # save the URL the user requested so we can hop back to it
      # after login
      redirect_to(openid_path)
    end
  end

  def set_jumpto<commit_msg>fixed bug, if config/secret.txt does not exist.<commit_after># Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  secret_path = File.join(RAILS_ROOT, "config/secret.txt")
  if File.exist?(secret_path)
    secret = open(secret_path) { |io| io.read }.gsub(/\s/, '')
  end
  if !secret || secret.empty?
    characters = ("0".."9").to_a + ("a".."f").to_a
    secret = Array.new(128) { characters[rand(characters.size)] }.join
    open(secret_path, "w") { |io| io.write(secret) }
  end

  protect_from_forgery :secret => secret
  
  # See ActionController::Base for details 
  # Uncomment this to filter the contents of submitted sensitive data parameters
  # from your application log (in this case, all fields with names like "password"). 
  # filter_parameter_logging :password
  
  I18n.default_locale = "ja"

  private
  def authorize
    unless session[:user_id] && (same_user = (session[:user_id].id == User.find(params["user"]).id))
      logger.debug "DEBUG(authorize) : session = <#{(session[:user_id]&&session[:user_id].to_yaml)}>, user = <#{User.find(params["id"] || params["user"]).to_yaml}>"
      flash[:notice] = t("permission_denied", :scope => %w(notice)) unless same_user
      flash[:notice] = t("please_log_in", :scope => %w(notice)) if same_user
      # save the URL the user requested so we can hop back to it
      # after login
      redirect_to(openid_path)
    end
  end

  def set_jumpto
{'fraction_non_alphanumeric': 0.12857555619763075, 'fraction_numerical': 0.004045073678127709, 'mean_word_length': 4.136498516320475, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '6413167', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1056, 'n_words': 320}