<commit_before>module Shoppe
  class ApplicationController < ActionController::Base
    
    protect_from_forgery
    
    before_filter :login_required
    
    rescue_from ActiveRecord::DeleteRestrictionError do |e|
      redirect_to request.referer || root_path, :alert => e.message
    end
    
    rescue_from Shoppe::Error do |e|
      @exception = e
      render :layout => 'shoppe/sub', :template => 'shoppe/shared/error'
    end

    private

    def login_required
      unless logged_in?
        redirect_to login_path
      end
    end

    def logged_in?
      current_user.is_a?(User)
    end
    
    def current_user
      @current_user ||= login_from_session || login_with_demo_mdoe || :false
    end

    def login_from_session
      if session[:shoppe_user_id]
        @user = User.find_by_id(session[:shoppe_user_id])
      end
    end
    
    def login_with_demo_mdoe
      if Shoppe.settings.demo_mode?
        @user = User.first
      end
    end
    
    helper_method :current_user, :logged_in?
    
  end
end<commit_msg>Just a small typo on method name<commit_after>module Shoppe
  class ApplicationController < ActionController::Base
    
    protect_from_forgery
    
    before_filter :login_required
    
    rescue_from ActiveRecord::DeleteRestrictionError do |e|
      redirect_to request.referer || root_path, :alert => e.message
    end
    
    rescue_from Shoppe::Error do |e|
      @exception = e
      render :layout => 'shoppe/sub', :template => 'shoppe/shared/error'
    end

    private

    def login_required
      unless logged_in?
        redirect_to login_path
      end
    end

    def logged_in?
      current_user.is_a?(User)
    end
    
    def current_user
      @current_user ||= login_from_session || login_with_demo_mode || :false
    end

    def login_from_session
      if session[:shoppe_user_id]
        @user = User.find_by_id(session[:shoppe_user_id])
      end
    end
    
    def login_with_demo_mode
      if Shoppe.settings.demo_mode?
        @user = User.first
      end
    end
    
    helper_method :current_user, :logged_in?
    
  end
end
{'fraction_non_alphanumeric': 0.07098911500236631, 'fraction_numerical': 0.0, 'mean_word_length': 2.471264367816092, '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': '4111820', 'n_tokens_mistral': 676, 'n_tokens_neox': 675, 'n_words': 147}