Sha256: 4c05a749b2739fcd5d4a4a2c4c12115c55d8c4f577e183dde205131245d1e800

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

class Spree::UsersController < Spree::StoreController
  skip_before_filter :set_current_order, :only => :show
  prepend_before_filter :load_object, :only => [:show, :edit, :update]
  prepend_before_filter :authorize_actions, :only => :new

  include Spree::Core::ControllerHelpers

  def show
    @orders = @user.orders.complete.order('completed_at desc')
  end

  def create
    @user = Spree::User.new(user_params)
    if @user.save

      if current_order
        session[:guest_token] = nil
      end

      redirect_back_or_default(root_url)
    else
      render :new
    end
  end

  def update
    if @user.update_attributes(user_params)
      if params[:user][:password].present?
        # this logic needed b/c devise wants to log us out after password changes
        user = Spree::User.reset_password_by_token(params[:user])
        sign_in(@user, :event => :authentication, :bypass => !Spree::Auth::Config[:signout_after_password_change])
      end
      redirect_to spree.account_url, :notice => Spree.t(:account_updated)
    else
      render :edit
    end
  end

  private
    def user_params
      params.require(:user).permit(Spree::PermittedAttributes.user_attributes)
    end

    def load_object
      @user ||= spree_current_user
      authorize! params[:action].to_sym, @user
    end

    def authorize_actions
      authorize! params[:action].to_sym, Spree::User.new
    end

    def accurate_title
      Spree.t(:my_account)
    end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
spree_auth_devise-3.1.0 lib/controllers/frontend/spree/users_controller.rb
spree_auth_devise-3.0.6 lib/controllers/frontend/spree/users_controller.rb
spree_auth_devise-3.0.5 lib/controllers/frontend/spree/users_controller.rb
solidus_auth_devise-1.2.2 lib/controllers/frontend/spree/users_controller.rb
solidus_auth_devise-1.2.1 lib/controllers/frontend/spree/users_controller.rb
solidus_auth_devise-1.2.0 lib/controllers/frontend/spree/users_controller.rb
solidus_auth_devise-1.1.0 lib/controllers/frontend/spree/users_controller.rb