<commit_before>class UserSessionsController < ApplicationController
  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => :destroy
  protect_from_forgery :except => [:create]
  
  def new
    @user_session = UserSession.new
    render :layout => (request.xhr?) ? false : true
  end
  
  def create
    @user_session = UserSession.new(params[:user_session])
    @user_session.save do |result|
      if result
        user = User.find_by_login(@user_session.login)
        apply_user_preferences(user)
        if request.xhr?
          #Text doesn't matter, status code does.
          render :text => 'Success!', :layout => false
        else
          redirect_back_or_default "/"
        end
      else
        render :action => :new, :layout => (request.xhr?) ? false : true, :status => :unprocessable_entity
      end
    end
  end
  
  def destroy
    destroy_user_preferences(current_user)<commit_msg>Updated apply_user_prefs to take user_session.user instead of find_by_login. Latter is cap sensitive.<commit_after>class UserSessionsController < ApplicationController
  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => :destroy
  protect_from_forgery :except => [:create]
  
  def new
    @user_session = UserSession.new
    render :layout => (request.xhr?) ? false : true
  end
  
  def create
    @user_session = UserSession.new(params[:user_session])
    @user_session.save do |result|
      if result
        apply_user_preferences(@user_session.user)
        if request.xhr?
          #Text doesn't matter, status code does.
          render :text => 'Success!', :layout => false
        else
          redirect_back_or_default "/"
        end
      else
        render :action => :new, :layout => (request.xhr?) ? false : true, :status => :unprocessable_entity
      end
    end
  end
  
  def destroy
    destroy_user_preferences(current_user)
{'fraction_non_alphanumeric': 0.10005130836326322, 'fraction_numerical': 0.0, 'mean_word_length': 3.020618556701031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6529742', 'n_tokens_mistral': 589, 'n_tokens_neox': 585, 'n_words': 146}