<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

  before_action :define_pages_and_social_links, :define_academy_level, :homepage?
  # before_action :authenticate_user!, :editor_only!, only: [:edit, :update, :delete]
  # Devise Parameters
  before_filter :configure_permitted_parameters, if: :devise_controller?

  def homepage?
    @homepage = (request.path =~ /^\/$/).present?
  end

  def after_sign_in_path_for(resource)
    artroom_path
  end

  def editor_only!
    unless current_user.editor? || current_user.admin?
      redirect_to new_user_session_path
    end
  end

  def admin_only!
    unless authenticate_user! && current_user.admin?
      redirect_to new_user_session_path
    end
  end

  def redirect_to_admin
    redirect_to admin_path
  end

  def not_found
    raise ActionController::RoutingError.new('Not Found')
  end

  protected
  # Devise Parameters
  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << [profile_attributes: [:first_name, :last_name, :avatar, :title, :school, :city, :state, :country, :occupation, :grades, :user_id]]
    devise_parameter_sanitizer.for(:account_update) << [:email, :password, :password_<PASSWORD>, :current_password, profile_attributes: [:first_name, :last_name, :avatar, :title, :school, :city, :state, :country, :occupation, :grades, :user_id]]
  end

  private
  def define_academy_level
    if ['upper', 'lower'].include? params[:academy]
      @academy = params[:academy].to_sym
    else<commit_msg>:wrench: fix devise strong params<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

  before_action :define_pages_and_social_links, :define_academy_level, :homepage?
  # before_action :authenticate_user!, :editor_only!, only: [:edit, :update, :delete]
  # Devise Parameters
  before_filter :configure_permitted_parameters, if: :devise_controller?

  def homepage?
    @homepage = (request.path =~ /^\/$/).present?
  end

  def after_sign_in_path_for(resource)
    artroom_path
  end

  def editor_only!
    unless current_user.editor? || current_user.admin?
      redirect_to new_user_session_path
    end
  end

  def admin_only!
    unless authenticate_user! && current_user.admin?
      redirect_to new_user_session_path
    end
  end

  def redirect_to_admin
    redirect_to admin_path
  end

  def not_found
    raise ActionController::RoutingError.new('Not Found')
  end

  protected
  # Devise Parameters
  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_up, keys: [profile_attributes: [:first_name, :last_name, :avatar, :title, :school, :city, :state, :country, :occupation, :grades, :user_id]])
    devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation, :current_password, profile_attributes: [:first_name, :last_name, :avatar, :title, :school, :city, :state, :country, :occupation, :grades, :user_id]])
  end

  private
  def define_academy_level
    if ['upper', 'lower'].include? params[:academy]
      @academy = params[:academy].to_sym
    else
{'fraction_non_alphanumeric': 0.1023200475907198, 'fraction_numerical': 0.0, 'mean_word_length': 5.016100178890877, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 4, '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': '1873877', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1083, 'n_words': 253}