Sha256: dd38f647eb7a85c40e979f376b2d8f749b1aa537b630f048f1477722ff1440d0

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

class UserSessionsController < Devise::SessionsController
  include SpreeBase
  helper :users, 'spree/base'

  include Spree::CurrentOrder

  after_filter :associate_user, :only => :create

  ssl_required :new, :create, :destroy, :update
  ssl_allowed :login_bar

  # GET /resource/sign_in
  def new
    super
  end

  def create
    authenticate_user!

    if user_signed_in?
      respond_to do |format|
        format.html {
          flash[:notice] = t("logged_in_succesfully")
          redirect_back_or_default(products_path)
        }
        format.js {
          user = resource.record
          render :json => {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json
        }
      end
    end
  end

  def destroy
    session.clear
    super
  end

  def nav_bar
    render :partial => "shared/nav_bar"
  end

  private

  def associate_user
    return unless current_user and current_order
    current_order.associate_user!(current_user)
    session[:guest_token] = nil
  end

  def accurate_title
    I18n.t(:log_in)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_auth-0.40.4 app/controllers/user_sessions_controller.rb
spree_auth-0.40.3 app/controllers/user_sessions_controller.rb
spree_auth-0.40.2 app/controllers/user_sessions_controller.rb
spree_auth-0.40.1 app/controllers/user_sessions_controller.rb
spree_auth-0.40.0 app/controllers/user_sessions_controller.rb