<commit_before>class UsersController < ApplicationController
  skip_before_filter :login_required, :only=>['login', 'new', 'forgot_password']

  def new
    @user = User.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @journal }
    end

  end
  
  def create
    @user = User.new(params[:user])

    respond_to do |format|
      if @user.save
        session[:user] = @user
        flash[:notice] = 'You have been registered.'
        format.html { redirect_to(@user) }
        format.xml  { render :xml => @account, :status => :created, :location => @account }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
      end
    end

  end
  
  def login
    if request.post?
      if session[:user] = User.authenticate(params[:login], params[:password])
        if not session[:user].current_company or not session[:user].current_company.in(session[:user].companies) and session[:user].companies.length > 0
            session[:user].current_company = session[:user].companies[0]
            session[:user].save
        end
        
        flash[:message]  = "Login successful"

	if session[:return_to]
          redirect_to session[:return_to]
        else
          redirect_to :action => :show, :id => session[:user].id
        end      
      else
        flash[:warning] = "Login unsuccessful"
      end
    end
  end

  def logout
    session[:user] = nil<commit_msg>signup shouldn't require being logged in<commit_after>class UsersController < ApplicationController
  skip_before_filter :login_required, :only => ['login', 'new', 'forgot_password', 'create']

  def new
    @user = User.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @journal }
    end

  end
  
  def create
    @user = User.new(params[:user])

    respond_to do |format|
      if @user.save
        session[:user] = @user
        flash[:notice] = 'You have been registered.'
        format.html { redirect_to(@user) }
        format.xml  { render :xml => @account, :status => :created, :location => @account }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
      end
    end
  end
  
  def login
    if request.post?
      if session[:user] = User.authenticate(params[:login], params[:password])
        if not session[:user].current_company or not session[:user].current_company.in(session[:user].companies) and session[:user].companies.length > 0
            session[:user].current_company = session[:user].companies[0]
            session[:user].save
        end
        
        flash[:notice]  = "Login successful"

	if session[:return_to]
          redirect_to session[:return_to]
        else
          redirect_to :action => :show, :id => session[:user].id
        end      
      else
        flash[:notice] = "Login unsuccessful"
      end
    end
  end

  def logout
    session[:user] = nil
{'fraction_non_alphanumeric': 0.12418725617685306, 'fraction_numerical': 0.0013003901170351106, 'mean_word_length': 2.4886621315192743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '7131299', 'n_tokens_mistral': 921, 'n_tokens_neox': 894, 'n_words': 224}