<commit_before>class SessionsController < ApplicationController
  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => :destroy

  def new
    oidreq = session[:last_oidreq]
    @username = username_for oidreq.identity if oidreq and not oidreq.id_select
  end

  def create
    oidreq = session[:last_oidreq]

    if params[:commit] != 'Log in'
      reset_session
      if oidreq
        redirect_to oidreq.cancel_url
      else
        redirect_to new_session_url, :notice => 'Login cancelled'
      end
    else<commit_msg>Better handling of id_select requests.<commit_after>class SessionsController < ApplicationController
  #TODO these tests may not be sensible when acting as an OpenID provider
  #before_filter :require_no_user, :only => [:new, :create]
  #before_filter :require_user, :only => :destroy

  def new
    oidreq = session[:last_oidreq]
    @username = username_for oidreq.identity if oidreq and not oidreq.id_select
    unless session[:username].blank?
      if @username
        flash[:notice] =
          "You are already logged in as #{session[:username]}." +
          " Do not press 'Login' unless you want to end that session."
      elsif oidreq.id_select
        if (session[:approvals] ||= []).include? oidreq.trust_root
          render_response(positive_response(oidreq, session[:username]))
        else
          redirect_to new_decision_path
        end
      end
    end
  end

  def create
    oidreq = session[:last_oidreq]

    if params[:commit] and params[:commit] != 'Log in'
      reset_session
      if oidreq
        redirect_to oidreq.cancel_url
      else
        redirect_to new_session_url, :notice => 'Login cancelled'
      end
    else
{'fraction_non_alphanumeric': 0.08434430964760255, 'fraction_numerical': 0.0, 'mean_word_length': 3.0657276995305165, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '806946', 'n_tokens_mistral': 522, 'n_tokens_neox': 505, 'n_words': 147}