Sha256: e33c3755164c81284a8e922822aa409ff1bae15fd0538e881494333f24d97e8b

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

module Clearance
  module App
    module Controllers
      module ConfirmationsController
    
        def self.included(controller)
          controller.class_eval do
            
            before_filter :existing_user?, :only => :new
            filter_parameter_logging :token
        
            def new
              create
            end

            def create
              @user.confirm_email!
              sign_user_in(@user)
              flash[:success] = "Confirmed email and signed in."
              redirect_to url_after_create
            end
        
            private
            
            def existing_user?
              @user = User.find_by_id_and_token(params[:user_id], params[:token])
              if @user.nil?
                render :nothing => true, :status => :not_found
              end
            end

            def url_after_create
              root_url
            end
            
          end
        end
        
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thoughtbot-clearance-0.4.2 lib/clearance/app/controllers/confirmations_controller.rb