<commit_before>class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  helper_method :gallery_editor_role?

  before_action :check_demo_user
  before_action :set_locale

  private

  def check_demo_user
    sign_out(current_user) if (current_user == demo_user) && (params[:controller] !~ /^api\//) && !(params[:controller] == 'pages' && params[:action] == 'demo')
  end

  def set_locale
    I18n.locale = session[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale
  end

  def gallery_editor_role?
    Gallery.instance.user_ids.include?(current_user.id)
  end

  def xhr_request?
    request.headers['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
  end

  def after_sign_in_path_for(resource)
    session[:user_return_to] || dashboard_path
  end

  def demo_user
    @@demo_user ||= User.find_by(name: 'demo')
  end
end
<commit_msg>Add nodes/edit_description as exception for check_demo_user<commit_after>class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  helper_method :gallery_editor_role?

  before_action :check_demo_user
  before_action :set_locale

  private

  def check_demo_user
    sign_out(current_user) if (current_user == demo_user) && (params[:controller] !~ /^api\//) && !(params[:controller] == 'pages' && params[:action] == 'demo') && !(params[:controller] == 'nodes' && params[:action] == 'edit_description')
  end

  def set_locale
    I18n.locale = session[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale
  end

  def gallery_editor_role?
    Gallery.instance.user_ids.include?(current_user.id)
  end

  def xhr_request?
    request.headers['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
  end

  def after_sign_in_path_for(resource)
    session[:user_return_to] || dashboard_path
  end

  def demo_user
    @@demo_user ||= User.find_by(name: 'demo')
  end
end

{'fraction_non_alphanumeric': 0.10968921389396709, 'fraction_numerical': 0.005484460694698354, 'mean_word_length': 5.06371191135734, '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': '2353861', 'n_tokens_mistral': 735, 'n_tokens_neox': 707, 'n_words': 149}