<commit_before>class UserSessionsController < ApplicationController
  def new
  end

  def create
    if params[:user_session][:login] == "yes"
      # Default to remember me
      @user_session = UserSession.new((params[:user_session] || {}).merge(:remember_me => true))
      @user_session.save do |result|
        if result
          new_user = @user_session.user.login_count == 1

          respond_to do |format|
            format.html do
              save_sprites_to_user(@user_session.user)

              flash[:notice] = "Login successful!"
              redirect_back_or_default root_path
            end
            format.json { render :json => {:status => "ok"} }
          end
        else
          respond_to do |format|
            format.html { render "new" }
            format.json do
              render :json => {
                :status => "error",
                :errors => @user_session.errors.full_messages
              }
            end
          end
        end
      end
    else
      session[:email] = params[:user_session][:email]

      redirect_to new_user_path
    end
  end

  def oauth
    provider = params[:provider]
    token = auth_hash["credentials"]["token"]

    current_user.update_oauth(provider, token)

    # render :text => "<pre>"+auth_hash.to_yaml+"</pre>"

    flash[:notice] = "#{provider} Authorized"
    redirect_to root_path
  end

  def destroy
    @user_session = UserSession.find
    @user_session.destroy if @user_session

    redirect_to root_url, :notice => "Successfully logged out."
  end

  protected

  def auth_hash
    request.env['omniauth.auth']
  end
end<commit_msg>Update login to use strong params<commit_after>class UserSessionsController < ApplicationController
  def new
  end

  def create
    if params[:user_session][:login] == "yes"
      # Default to remember me
      @user_session = UserSession.new(user_session_params.merge(:remember_me => true))
      @user_session.save do |result|
        if result
          new_user = @user_session.user.login_count == 1

          respond_to do |format|
            format.html do
              save_sprites_to_user(@user_session.user)

              flash[:notice] = "Login successful!"
              redirect_back_or_default root_path
            end
            format.json { render :json => {:status => "ok"} }
          end
        else
          respond_to do |format|
            format.html { render "new" }
            format.json do
              render :json => {
                :status => "error",
                :errors => @user_session.errors.full_messages
              }
            end
          end
        end
      end
    else
      session[:email] = params[:user_session][:email]

      redirect_to new_user_path
    end
  end

  def oauth
    provider = params[:provider]
    token = auth_hash["credentials"]["token"]

    current_user.update_oauth(provider, token)

    # render :text => "<pre>"+auth_hash.to_yaml+"</pre>"

    flash[:notice] = "#{provider} Authorized"
    redirect_to root_path
  end

  def destroy
    @user_session = UserSession.find
    @user_session.destroy if @user_session

    redirect_to root_url, :notice => "Successfully logged out."
  end

  protected

  def auth_hash
    request.env['omniauth.auth']
  end

  def user_session_params
    params.require(:user_session).permit(:email, :password, :login)
  end
end
{'fraction_non_alphanumeric': 0.09985272459499264, 'fraction_numerical': 0.000589101620029455, 'mean_word_length': 2.1708683473389354, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '7476267', 'n_tokens_mistral': 996, 'n_tokens_neox': 962, 'n_words': 225}