<commit_before>require 'action_view/helpers'

module BambooUser
  class Engine < ::Rails::Engine
    isolate_namespace BambooUser
  end

  class Railtie < ::Rails::Railtie
    initializer "bamboo_users.settings_filters" do
      ActionController::Base.class_eval do

        def logged_user
          @logged_user ||= BambooUser::User.find_by(auth_token: cookies[:auth_token_p]) if cookies[:auth_token_p]
          @logged_user ||= BambooUser::User.find_by(id: session[:user])
          @logged_user
        end

        def logged_in?
          (not logged_user.nil?)
        end

        def fetch_logged_user
          redirect_to(eval(BambooUser.login_screen_path), notice: 'Login is required. Please login here') unless logged_in? if restrict_access?
        end

        def restrict_access?
          _restrict_access = true
          if BambooUser.public_paths.is_a?(Hash)
            BambooUser.public_paths.stringify_keys!
            if BambooUser.public_paths.keys.include?(params['controller'])
              if BambooUser.public_paths[params['controller']].is_a?(Array)
                _actions = BambooUser.public_paths[params['controller']].collect { |x| x.to_s }
                _restrict_access = false if _actions.include?(BambooUser.all_actions) or _actions.include?(params['action'])
              end
            end
          end
          _restrict_access
        end

        # Stores last url visited which is needed for post login redirect
        def store_location
          return if request.xhr? or (not request.get?)

          if request.format == "text/html" or request.content_type == "text/html"
            #request.path != "/users/sign_in" &&
            #request.path != "/users/sign_up" &&
            #request.path != "/users/invitation_sign_up" &&
            #request.path != "/users/password/new" &&
            #request.path != "/users/password/edit" &&
            #request.path != "/users/confirmation" &&
            #request.path != "/users/sign_out"
            session[:previous_url] = request.fullpath unless [bamboo_user.login_path,
                                                              bamboo_user.logout_path,
                                                              bamboo_user.reset_password_path,
                                                              bamboo_user.sign_up_path,
                                                              bamboo_user.invitation_sign_up_path].include?(request.path)<commit_msg>Adding custom_signup_path to ignorable list of previous_url so that it cant be used while redirecting back after login<commit_after>require 'action_view/helpers'

module BambooUser
  class Engine < ::Rails::Engine
    isolate_namespace BambooUser
  end

  class Railtie < ::Rails::Railtie
    initializer "bamboo_users.settings_filters" do
      ActionController::Base.class_eval do

        def logged_user
          @logged_user ||= BambooUser::User.find_by(auth_token: cookies[:auth_token_p]) if cookies[:auth_token_p]
          @logged_user ||= BambooUser::User.find_by(id: session[:user])
          @logged_user
        end

        def logged_in?
          (not logged_user.nil?)
        end

        def fetch_logged_user
          redirect_to(eval(BambooUser.login_screen_path), notice: 'Login is required. Please login here') unless logged_in? if restrict_access?
        end

        def restrict_access?
          _restrict_access = true
          if BambooUser.public_paths.is_a?(Hash)
            BambooUser.public_paths.stringify_keys!
            if BambooUser.public_paths.keys.include?(params['controller'])
              if BambooUser.public_paths[params['controller']].is_a?(Array)
                _actions = BambooUser.public_paths[params['controller']].collect { |x| x.to_s }
                _restrict_access = false if _actions.include?(BambooUser.all_actions) or _actions.include?(params['action'])
              end
            end
          end
          _restrict_access
        end

        # Stores last url visited which is needed for post login redirect
        def store_location
          return if request.xhr? or (not request.get?)

          if request.format == "text/html" or request.content_type == "text/html"
            #request.path != "/users/sign_in" &&
            #request.path != "/users/sign_up" &&
            #request.path != "/users/invitation_sign_up" &&
            #request.path != "/users/password/new" &&
            #request.path != "/users/password/edit" &&
            #request.path != "/users/confirmation" &&
            #request.path != "/users/sign_out"
            session[:previous_url] = request.fullpath unless [
                bamboo_user.login_path,
                bamboo_user.logout_path,
                bamboo_user.reset_password_path,
                bamboo_user.invitation_sign_up_path,
                (BambooUser.custom_signup_path.nil? ? bamboo_user.sign_up_path : eval(BambooUser.custom_signup_path))
            ].compact.include?(request.path)
{'fraction_non_alphanumeric': 0.09712804148384524, 'fraction_numerical': 0.0, 'mean_word_length': 2.126558603491272, 'pattern_counts': {'":': 0, '<': 7, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2195375', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1371, 'n_words': 265}