<commit_before>class UserSessionsController < ApplicationController
  before_action :display_first_time_canvas_notice, :only => [:new]
  protect_from_forgery :except => [:create]

  def index
    redirect_to root_url
  end

  def new
    redirect_to root_url and return if current_user.present?

    @user_session = UserSession.new
    render :layout => !request.xhr?
  end

  def create
    redirect_to root_url and return if current_user.present?

    @user_session = UserSession.new(params[:user_session])
    @user_session.save do |result|
      if result
        apply_user_preferences(@user_session.user, false)
        if request.xhr?
          #Text doesn't matter, status code does.
          render :text => 'Success!', :layout => false
        else
          if first_time_canvas_login?
            save_canvas_id_to_user(@user_session.user)
            flash[:notice] = "You canvas id was attached to this account"
            redirect_to user_path(@user_session.user)
          else
            redirect_back_or_default "/"
          end
        end
      else
        render :action => :new, :layout => !request.xhr?, :status => :unprocessable_entity
      end
    end
  end

  def destroy
    destroy_user_preferences
    if current_user_session.present?
      current_user_session.destroy
    end
    redirect_back_or_default "/"
  end
end
<commit_msg>fix login with StrongAttributes<commit_after>class UserSessionsController < ApplicationController
  protect_from_forgery :except => [:create]
  before_action :display_first_time_canvas_notice, :only => [:new]

  def index
    redirect_to root_url
  end

  def new
    redirect_to root_url and return if current_user.present?

    @user_session = UserSession.new
    render :layout => !request.xhr?
  end

  def create
    redirect_to root_url and return if current_user.present?

    @user_session = UserSession.new(user_session_param)
    @user_session.save do |result|
      if result
        apply_user_preferences(@user_session.user, false)
        if request.xhr?
          #Text doesn't matter, status code does.
          render :text => 'Success!', :layout => false
        else
          if first_time_canvas_login?
            save_canvas_id_to_user(@user_session.user)
            flash[:notice] = "You canvas id was attached to this account"
            redirect_to user_path(@user_session.user)
          else
            redirect_back_or_default "/"
          end
        end
      else
        render :action => :new, :layout => !request.xhr?, :status => :unprocessable_entity
      end
    end
  end

  def destroy
    destroy_user_preferences
    if current_user_session.present?
      current_user_session.destroy
    end
    redirect_back_or_default "/"
  end

  private

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

{'fraction_non_alphanumeric': 0.07566248256624826, 'fraction_numerical': 0.0, 'mean_word_length': 2.8, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '241660', 'n_tokens_mistral': 853, 'n_tokens_neox': 835, 'n_words': 208}