Sha256: 824212b206de8942ea92ad45c14cf166cefeebc1833ab30ed7d2ce0af02a01c4

Contents?: true

Size: 1.95 KB

Versions: 36

Compression:

Stored size: 1.95 KB

Contents

module Caboose
  class MyAccountOrdersController < Caboose::ApplicationController
            
    # GET /my-account/orders
    def index
      return if !logged_in?
      
      @pager = Caboose::PageBarGenerator.new(params, {
        'customer_id'          => logged_in_user.id,         
        'status'               => [Order::STATUS_PENDING, Order::STATUS_CANCELED, Order::STATUS_SHIPPED]
      }, {
        'model'          => 'Caboose::Order',
        'sort'           => 'order_number',
        'desc'           => 1,
        'base_url'       => '/my-account/orders',
        'use_url_params' => false
      })      
      @orders = @pager.all_items
    end
      
    # GET /my-account/orders/:id
    def edit
      return if !logged_in?
      
      @order = Order.find(params[:id])
      if @order.customer_id != logged_in_user.id
        @error = "The given order does not belong to you."
        render :file => 'caboose/extras/error'
        return
      end      
    end
     # GET /my-account
    def my_account
      return if !logged_in?
      @user = logged_in_user
      render :layout => 'caboose/modal'
    end
    
    # PUT /my-account
    def update_my_account  
      return if !logged_in?
      
      resp = StdClass.new     
      user = logged_in_user
    
      save = true
      params.each do |name,value|
        case name
    	  	when "first_name", "last_name", "username", "email", "phone"
    	  	  user[name.to_sym] = value
    	  	when "password"			  
    	  	  confirm = params[:confirm]
    	  		if (value != confirm)			
    	  		  resp.error = "Passwords do not match.";
    	  		  save = false
    	  		elsif (value.length < 8)
    	  		  resp.error = "Passwords must be at least 8 characters.";
    	  		  save = false
    	  		else
    	  		  user.password = Digest::SHA1.hexdigest(Caboose::salt + value)
    	  		end    	  	    		  
    	  end
    	end
    	
    	resp.success = save && user.save
    	render json: resp
    end        
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
caboose-cms-0.5.159 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.158 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.156 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.155 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.154 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.153 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.152 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.151 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.150 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.149 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.148 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.147 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.146 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.145 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.144 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.143 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.142 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.141 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.140 app/controllers/caboose/my_account_orders_controller.rb
caboose-cms-0.5.139 app/controllers/caboose/my_account_orders_controller.rb