<commit_before>module Clearance
  module App
    module Controllers
      module UsersController

        def self.included(base)
          base.class_eval do
            filter_parameter_logging :password, :password_confirmation, :old_password
            
            before_filter :login_required, :only => [:change_password, :edit_password]
            
            include InstanceMethods
        
          private
            include PrivateInstanceMethods
          end
        end

        module InstanceMethods
          def new
            @user = user_model.new(params[:user])
          end
      
          def create
            @user = user_model.new params[:user]
            if @user.save
              ClearanceMailer.deliver_confirmation @user
              flash[:notice] = "You will receive an email within the next few minutes. It contains instructions for you to confirm your account."
              redirect_to url_after_create
            else
              render :action => "new"
            end
          end
          
          def edit_password
            @user = <PASSWORD>
          end
          
          def change_password
            @user = current_user
            
            if @user.change_password(params[:user])
              flash[:notice] = "Password changed successfully."
              after_successful_change_password
            else
              render :action => "edit_password"
            end
          end
          
        end

        module PrivateInstanceMethods

          def after_successful_change_password
            redirect_to user_path(current_user)
          end
          
          def url_after_create
            new_session_url
          end
        
          def url_after_change_password
            user_path(current_user)
          end
        end

      end
    end
  end<commit_msg>added callback structure to user create<commit_after>module Clearance
  module App
    module Controllers
      module UsersController

        def self.included(base)
          base.class_eval do
            filter_parameter_logging :password, :password_confirmation, :old_password
            
            before_filter :login_required, :only => [:change_password, :edit_password]
            
            include InstanceMethods
        
          private
            include PrivateInstanceMethods
          end
        end

        module InstanceMethods
          def new
            @user = user_model.new(params[:user])
          end
      
          def create
            @user = user_model.create params[:user]
            @user.save ? create_successful : create_failed
          end
          
          def edit_password
            @user = current_user
          end
          
          def change_password
            @user = current_user
            
            if @user.change_password(params[:user])
              flash[:notice] = "Password changed successfully."
              after_successful_change_password
            else
              render :action => "edit_password"
            end
          end
          
        end

        module PrivateInstanceMethods
          
          def create_successful
            ClearanceMailer.deliver_confirmation @user
            flash[:notice] = "You will receive an email within the next few minutes. It contains instructions for you to confirm your account."
            redirect_to url_after_create
          end
          
          def create_failed
            render :action => "new"
          end

          def after_successful_change_password
            redirect_to user_path(current_user)
          end
          
          def url_after_create
            new_session_url
          end
        
          def url_after_change_password
            user_path(current_user)
          end
        end

      end
    end
  end
{'fraction_non_alphanumeric': 0.042344435837851795, 'fraction_numerical': 0.0, 'mean_word_length': 1.389882788402221, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, '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': '3742487', 'n_tokens_mistral': 888, 'n_tokens_neox': 887, 'n_words': 237}