<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_filter :configure_permitted_parameters, if: :devise_controller?
  before_action :set_locale

  protected

  def self.default_url_options(options={})
    if I18n.locale != I18n.default_locale
      options.merge({locale: I18n.locale})
    else
      options
    end
  end

  def requested_locale
    if user_signed_in?
      current_user.locale
    else
      if params[:locale].present? && I18n.available_locales.include?(params[:locale].to_sym)
        params[:locale].to_sym
      end
    end
  end

  def set_locale
    I18n.locale = requested_locale || I18n.default_locale
  end

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up).push(*[:name, :username, :email])
    devise_parameter_sanitizer.for(:sign_in).push(*[:username])
    devise_parameter_sanitizer.for(:account_update).push(*[:name, :username,
                                                           :email, :url, :locale,
                                                           :twitter, :privacy,
                                                           :github, :jabber,
                                                           :gpg_fingerprint,
                                                           :pin, :pin_confirmation,
                                                           phone_numbers_attributes: [
                                                             :_destroy,
                                                             :id,
                                                             :phone_number<commit_msg>Remove devise deprecation warnings.<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_filter :configure_permitted_parameters, if: :devise_controller?
  before_action :set_locale

  protected

  def self.default_url_options(options={})
    if I18n.locale != I18n.default_locale
      options.merge({locale: I18n.locale})
    else
      options
    end
  end

  def requested_locale
    if user_signed_in?
      current_user.locale
    else
      if params[:locale].present? && I18n.available_locales.include?(params[:locale].to_sym)
        params[:locale].to_sym
      end
    end
  end

  def set_locale
    I18n.locale = requested_locale || I18n.default_locale
  end

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :username, :email])
    devise_parameter_sanitizer.permit(:sign_in, keys: [:username])
    devise_parameter_sanitizer.permit(:account_update, keys: [:name, :username,
                                                           :email, :url, :locale,
                                                           :twitter, :privacy,
                                                           :github, :jabber,
                                                           :gpg_fingerprint,
                                                           :pin, :pin_confirmation,
                                                           phone_numbers_attributes: [
                                                             :_destroy,
                                                             :id,
                                                             :phone_number
{'fraction_non_alphanumeric': 0.07061121964833939, 'fraction_numerical': 0.0066982975160480044, 'mean_word_length': 1.3578947368421053, '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': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4140157', 'n_tokens_mistral': 841, 'n_tokens_neox': 806, 'n_words': 170}