<commit_before>class UsersController < ApplicationController
  before_filter :check_existing_user, only: :callback

  def callback
    @user = User.new
    @user.send("create_user_#{request.env['omniauth.auth'][:provider]}",request.env["omniauth.auth"])

    respond_to do |format|
      if @user.save
        session["user"] = {username: @user.username, login_type: @user.login_type}
        format.html { redirect_to root_url, notice: 'User was successfully created.' }
        format.json { render json: @user, status: :created, location: @user }
      else
        format.html { redirect_to root_url, error: "There was an error with signing up with that account." }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

  def logout
    session.clear
    redirect_to root_url, notice: "Successfully logged out"
  end

  private

  def check_existing_user
    user = User.send("find_by_username_for_#{request.env['omniauth.auth'][:provider]}", request.env["omniauth.auth"])
    if user
      session["user"] = {username: user.username, login_type: user.login_type}
      redirect_to root_url
    else
      session.clear
    end
  end
end<commit_msg>checking some log info.<commit_after>class UsersController < ApplicationController
  before_filter :check_existing_user, only: :callback

  def callback
    @user = User.new
    @user.send("create_user_#{request.env['omniauth.auth'][:provider]}",request.env["omniauth.auth"])

    respond_to do |format|
      if @user.save
        session["user"] = {username: @user.username, login_type: @user.login_type}
        format.html { redirect_to root_url, notice: 'User was successfully created.' }
        format.json { render json: @user, status: :created, location: @user }
      else
        format.html { redirect_to root_url, error: "There was an error with signing up with that account." }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

  def logout
    session.clear
    redirect_to root_url, notice: "Successfully logged out"
  end

  private

  def check_existing_user
    user = User.send("find_by_username_for_#{request.env['omniauth.auth'][:provider]}", request.env["omniauth.auth"])
    if user
      session["user"] = {username: user.username, login_type: user.login_type}
      redirect_to root_url
    else
      logger.info request.env['omniauth.auth'][:provider]
      logger.info request.env['omniauth.auth'][:info]
      logger.info "No previous user found."
      session.clear
    end
  end
end
{'fraction_non_alphanumeric': 0.11296583850931677, 'fraction_numerical': 0.0, 'mean_word_length': 3.5052447552447554, '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': '6627593', 'n_tokens_mistral': 784, 'n_tokens_neox': 766, 'n_words': 195}