Class: Spree::UsersController

Inherits:
StoreController
  • Object
show all
Includes:
Core::ControllerHelpers
Defined in:
lib/controllers/frontend/spree/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/controllers/frontend/spree/users_controller.rb', line 12

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

#showObject



8
9
10
# File 'lib/controllers/frontend/spree/users_controller.rb', line 8

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

#updateObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/controllers/frontend/spree/users_controller.rb', line 26

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
      Spree::User.reset_password_by_token(params[:user])
      if Spree::Auth::Config[:signout_after_password_change]
        (@user, event: :authentication)
      else
        (@user)
      end
    end
    redirect_to spree., notice: Spree.t(:account_updated)
  else
    render :edit
  end
end