<commit_before>class Users::SessionsController < Devise::SessionsController

  layout "client"

  def new
    
    # Set return path if available
    # params[:return_path] is used in the SessionController to
    # create the correct return path.
    session[:"user.return_to"] = if params[:return_path]
      then params[:return_path]
      else nil
      end
    
    
    # Toggle the layout
    unless params[:layout].nil?
      # Default login
      render "users/sessions/new", :layout => "accounting"
      return false
    else
      # Client login
      render "user_sessions/new"
      return false
    end
    
    super
  end
  
  def create
    
    # Check if a fact should be added
    if user_signed_in?
      # If the fact to create is set, the user was not logged in before but did\
      # want to add a fact.
      #
      # User is logged in now, so create the fact and redirect to the correct page.
      if session[:fact_to_create]
        fact_hash     = session[:fact_to_create]

        url           = fact_hash['url']
        displaystring = fact_hash['fact']


        # Clear fact_to_create
        session[:fact_to_create] = nil
        
        site = Site.find_or_create_by(:url => url)
        # Create the Fact
        @factlink = Fact.create!(:displaystring => displaystring, 
                                        :created_by => current_user,
                                        :site => site)

        redirect_to(@factlink)
        return false
      end
    end

    super
  end
  
  def destroy
    super
  end
  
end<commit_msg>fixed the loginprocess (especially the creation of a fact in the session)<commit_after>class Users::SessionsController < Devise::SessionsController

  layout "client"

  def new
    
    # Set return path if available
    # params[:return_path] is used in the SessionController to
    # create the correct return path.
    session[:"user.return_to"] = if params[:return_path]
      then params[:return_path]
      else nil
      end
    
    
    # Toggle the layout
    unless params[:layout].nil?
      # Default login
      render "users/sessions/new", :layout => "accounting"
      return false
    else
      # Client login
      render "user_sessions/new"
      return false
    end
    
    super
  end
  
  def create
    
    # Check if a fact should be added
    if user_signed_in?
      # If the fact to create is set, the user was not logged in before but did\
      # want to add a fact.
      #
      # User is logged in now, so create the fact and redirect to the correct page.
      if session[:fact_to_create]
        fact_hash     = session[:fact_to_create]

        url           = fact_hash['url']
        displaystring = fact_hash['fact']


        # Clear fact_to_create
        session[:fact_to_create] = nil
        
        site = Site.find_or_create_by(:url => url)
        # Create the Fact
        @fact = Fact.create!()
        @fact.displaystring = displaystring
        @fact.created_by = current_user.graph_user
        @fact.site = site
        @fact.save

        redirect_to :controller => "/facts", :action => "show", :id => @fact.id
        return false
      end
    end

    super
  end
  
  def destroy
    super
  end
  
end
{'fraction_non_alphanumeric': 0.07466831224930577, 'fraction_numerical': 0.0, 'mean_word_length': 1.9445958219800181, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6264738', 'n_tokens_mistral': 929, 'n_tokens_neox': 907, 'n_words': 296}