<commit_before>class UserSessionsController < ApplicationController

  helper_method :captcha_required?

  # don't need to authorize here (except for destroy action) because anyone can see log in page
  skip_authorization_check

  before_filter(:ensure_logged_out, :only => [:new, :destroy, :logged_out])

  def new
    @user_session = UserSession.new
  end

  def create
    # reset the session for security purposes
    reset_session_preserving_return_to

    @user_session = UserSession.new(params[:user_session])

    # if the save is successful, the user is logged in automatically
    if allow_login && @user_session.save
      post_login_housekeeping
    else
      flash[:error] = @user_session.errors.full_messages.join(",")
      redirect_to(:action => :new)
    end
  end

  def destroy
    forget_location
    redirect_to(logged_out_url)
  end

  # shows a simple 'you are logged out' page
  def logged_out
  end

  def login_confirmation
    authorize!(:confirm_login, UserSession)

    @user_session = UserSession.new
  end

  def process_login_confirmation
    authorize!(:confirm_login, UserSession)

    params[:user_session][:login] = current_user.login

    @user_session = UserSession.new(params[:user_session])

    # if the save is successful, the user is logged in automatically
    if allow_login && @user_session.save
      post_login_housekeeping
    else
      flash[:error] = @user_session.errors.full_messages.join(",")
      redirect_to(login_confirmation_url)
    end
  end

  # Special route, test only, used by feature specs to simulate user login.
  def test_login
    return render text: 'TEST MODE ONLY', status: 403 unless Rails.env.test?
    @user = User.find(params[:user_id])
    UserSession.create(@user)
    post_login_housekeeping(dont_redirect: true)

    # We redirect to user profile instead of dashboard because dashboard is slower to load and is not needed.
    redirect_to user_path(@user, locale: 'en', mode: 'm', mission_name: @user.best_mission.compact_name)
  end

  private
<commit_msg>204: Use strong parameters for UserSessionsController<commit_after>class UserSessionsController < ApplicationController

  helper_method :captcha_required?

  # don't need to authorize here (except for destroy action) because anyone can see log in page
  skip_authorization_check

  before_filter(:ensure_logged_out, :only => [:new, :destroy, :logged_out])

  def new
    @user_session = UserSession.new
  end

  def create
    # reset the session for security purposes
    reset_session_preserving_return_to

    @user_session = UserSession.new(user_session_params)

    # if the save is successful, the user is logged in automatically
    if allow_login && @user_session.save
      post_login_housekeeping
    else
      flash[:error] = @user_session.errors.full_messages.join(",")
      redirect_to(:action => :new)
    end
  end

  def destroy
    forget_location
    redirect_to(logged_out_url)
  end

  # shows a simple 'you are logged out' page
  def logged_out
  end

  def login_confirmation
    authorize!(:confirm_login, UserSession)

    @user_session = UserSession.new
  end

  def process_login_confirmation
    authorize!(:confirm_login, UserSession)

    params[:user_session][:login] = current_user.login

    @user_session = UserSession.new(user_session_params)

    # if the save is successful, the user is logged in automatically
    if allow_login && @user_session.save
      post_login_housekeeping
    else
      flash[:error] = @user_session.errors.full_messages.join(",")
      redirect_to(login_confirmation_url)
    end
  end

  # Special route, test only, used by feature specs to simulate user login.
  def test_login
    return render text: 'TEST MODE ONLY', status: 403 unless Rails.env.test?
    @user = User.find(params[:user_id])
    UserSession.create(@user)
    post_login_housekeeping(dont_redirect: true)

    # We redirect to user profile instead of dashboard because dashboard is slower to load and is not needed.
    redirect_to user_path(@user, locale: 'en', mode: 'm', mission_name: @user.best_mission.compact_name)
  end

  private

    def user_session_params
      params.require(:user_session).permit(:login, :password)
    end

{'fraction_non_alphanumeric': 0.07758007117437722, 'fraction_numerical': 0.002135231316725979, 'mean_word_length': 3.96, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6334391', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1228, 'n_words': 358}