<commit_before>module Clearance
  module App
    module Controllers
      module ApplicationController
    
        def self.included(controller)
          controller.class_eval do
            
            helper_method :current_user
            helper_method :signed_in?
        
            def current_user
              user_from_session || user_from_cookie
            end

            def signed_in?
              ! current_user.nil?
            end
            
            protected
            
            def authenticate
              deny_access unless signed_in?
            end

            def user_from_session
              if session[:user_id] && session[:salt]
                user = User.find_by_id_and_salt(session[:user_id], session[:salt])
              end
              user && user.email_confirmed? ? user : nil
            end

            def user_from_cookie
              if cookies[:remember_token]
                user = User.find_by_remember_token(cookies[:remember_token])
              end
              user && user.remember? ? user : nil
            end

            # Hook
            def sign_user_in(user)
              sign_in(user)
            end

            def sign_in(user)
              if user
                session[:user_id] = user.id
                session[:salt]    = user.salt
              end
            end

            def redirect_back_or(default)
              session[:return_to] ||= params[:return_to]
              if session[:return_to] 
                redirect_to(session[:return_to])
              else 
                redirect_to(default)
              end
              session[:return_to] = nil
            end

            def redirect_to_root
              redirect_to root_url
            end

            def store_location
              session[:return_to] = request.request_uri
            end

            def deny_access(flash_message = nil, opts = {})
              store_location
              flash[:failure] = flash_message if flash_message
              render :template => "/sessions/new", :status => :unauthorized 
            end
            
          end
        end
        
      end
    end
  end
end
<commit_msg>Made current_user and signed_in? actions hidden<commit_after>module Clearance
  module App
    module Controllers
      module ApplicationController
    
        def self.included(controller)
          controller.class_eval do
                      
            helper_method :current_user
            helper_method :signed_in?
            
            hide_action :current_user, :signed_in?
        
            def current_user
              user_from_session || user_from_cookie
            end

            def signed_in?
              ! current_user.nil?
            end
            
            protected
            
            def authenticate
              deny_access unless signed_in?
            end

            def user_from_session
              if session[:user_id] && session[:salt]
                user = User.find_by_id_and_salt(session[:user_id], session[:salt])
              end
              user && user.email_confirmed? ? user : nil
            end

            def user_from_cookie
              if cookies[:remember_token]
                user = User.find_by_remember_token(cookies[:remember_token])
              end
              user && user.remember? ? user : nil
            end

            # Hook
            def sign_user_in(user)
              sign_in(user)
            end

            def sign_in(user)
              if user
                session[:user_id] = user.id
                session[:salt]    = user.salt
              end
            end

            def redirect_back_or(default)
              session[:return_to] ||= params[:return_to]
              if session[:return_to] 
                redirect_to(session[:return_to])
              else 
                redirect_to(default)
              end
              session[:return_to] = nil
            end

            def redirect_to_root
              redirect_to root_url
            end

            def store_location
              session[:return_to] = request.request_uri
            end

            def deny_access(flash_message = nil, opts = {})
              store_location
              flash[:failure] = flash_message if flash_message
              render :template => "/sessions/new", :status => :unauthorized 
            end
            
          end
        end
        
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.05766681396376491, 'fraction_numerical': 0.0, 'mean_word_length': 1.1764423076923076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7055688', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1073, 'n_words': 242}