<commit_before>class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  before_filter :require_valid_omniauth, only: :nyulibraries
  def nyulibraries
    # Find existing or initialize new user,
    # and save new attributes each time
    @user = find_user_with_or_without_provider.first_or_initialize(attributes_from_omniauth)
    @user.update_attributes(attributes_from_omniauth)

    if @user.persisted?
      sign_in_and_redirect @user, event: :authentication
      set_flash_message(:notice, :success, kind: "NYU Libraries") #if is_navigational_format?
    else
      session["devise.nyulibraries_data"] = request.env["omniauth.auth"]
      redirect_to root_path
    end
  end

  def find_user_with_or_without_provider
    @find_user_with_or_without_provider ||= (find_user_with_provider.present?) ? find_user_with_provider : find_user_without_provider
  end

  def find_user_with_provider<commit_msg>Log the success, dont set as flash message<commit_after>class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  before_filter :require_valid_omniauth, only: :nyulibraries
  def nyulibraries
    # Find existing or initialize new user,
    # and save new attributes each time
    @user = find_user_with_or_without_provider.first_or_initialize(attributes_from_omniauth)
    @user.update_attributes(attributes_from_omniauth)

    if @user.persisted?
      sign_in_and_redirect @user, event: :authentication
      logger.info(find_message(:success, kind: "NYU Libraries"))
    else
      session["devise.nyulibraries_data"] = request.env["omniauth.auth"]
      redirect_to root_path
    end
  end

  def find_user_with_or_without_provider
    @find_user_with_or_without_provider ||= (find_user_with_provider.present?) ? find_user_with_provider : find_user_without_provider
  end

  def find_user_with_provider
{'fraction_non_alphanumeric': 0.0688912809472551, 'fraction_numerical': 0.0, 'mean_word_length': 5.592198581560283, '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': '822833', 'n_tokens_mistral': 580, 'n_tokens_neox': 565, 'n_words': 109}