Class: Spree::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spree/users_controller.rb', line 10

def create
  @user = Spree::User.new(params[:user])
  if @user.save

    if current_order
      current_order.associate_user!(@user)
      session[:guest_token] = nil
    end

    redirect_back_or_default(root_url)
  else
    render :new
  end
end

#showObject



6
7
8
# File 'app/controllers/spree/users_controller.rb', line 6

def show
  @orders = @user.orders.complete
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/spree/users_controller.rb', line 25

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