Sha256: 4b0afc5e9604cb3679e3c98b5083fa8bcb64ef89092f749946de1c75e0f100df

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

class UsersController < Spree::BaseController
  resource_controller

  ssl_required :new, :create, :edit, :update, :show

  actions :all, :except => [:index, :destroy]

  show.before do
    @orders = @user.orders.complete
  end

  create.after do
    create_session
    associate_user
  end

  create.flash nil
  create.wants.html { redirect_back_or_default(root_url) }

  new_action.before do
    flash.now[:notice] = I18n.t(:please_create_user) unless User.admin_created?
  end

  update.wants.html { redirect_to account_url }

  update.after do
    create_session
  end

  update.flash I18n.t("account_updated")

  private
  def object
    @object ||= current_user
  end

  def accurate_title
    I18n.t(:account)
  end

  def associate_user
    return unless current_order and @user.valid?
    current_order.associate_user!(@user)
    session[:guest_token] = nil
  end

  def create_session
    session_params = params[:user]
    session_params[:login] = session_params[:email]
    UserSession.create session_params
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_auth-0.30.2 app/controllers/users_controller.rb
spree_auth-0.30.1 app/controllers/users_controller.rb
spree_auth-0.30.0 app/controllers/users_controller.rb