<commit_before>class SessionsController < ApplicationController

  def new
    @user = User.new
    render :new, layout: false
  end

  def create
    @user = User.find_by(username: params[:user][:username]).try(:authenticate, params[:user][:password])
    respond_to do |format|
      if @user
        set_session
        format.html { redirect_to @user }
        format.json { render json: :user, status: :logged, location: @user }
      else
        format.html { redirect_to login_path }
        format.json { render json: @user.errors }
      end
    end
  end

  def destroy
    session.clear
    redirect_to '/'
  end
end<commit_msg>Fix redirect for invalid logins<commit_after>class SessionsController < ApplicationController

  def new
    @user = User.new
    render :new, layout: false
  end

  def create
    @user = User.find_by(username: params[:user][:username]).try(:authenticate, params[:user][:password])
    respond_to do |format|
      if @user
        set_session
        format.html { redirect_to @user }
        format.json { render json: :user, status: :logged, location: @user }
      else
        format.html { redirect_to '/' }
        format.json { render json: @user.errors }
      end
    end
  end

  def destroy
    session.clear
    redirect_to '/'
  end
end
{'fraction_non_alphanumeric': 0.10147172734314484, 'fraction_numerical': 0.0, 'mean_word_length': 2.6497175141242937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5380297', 'n_tokens_mistral': 391, 'n_tokens_neox': 380, 'n_words': 106}