Sha256: 6284043e101079281c4d9652f15b4918acf25fc80631b0f6c87ff952de2b11b1

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

class UserSessionsController < Spree::BaseController
  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => :destroy
  ssl_required :new, :create, :destroy, :update
  ssl_allowed :login_bar
    
  def new
    @user_session = UserSession.new
  end

  def create
    @user_session = UserSession.new(params[:user_session])
    success = @user_session.save 
    respond_to do |format|
      format.html {                                
        if success 
          flash[:notice] = t("logged_in_succesfully")
          redirect_back_or_default products_path
        else
          flash.now[:error] = t("login_failed")
          render :new
        end
      }
      format.js {
        user = success ? @user_session.record : nil
        render :json => user ? {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json : success.to_json
      }
    end    
  end

  def destroy
    current_user_session.destroy
    flash[:notice] = t("logged_out")
    redirect_to products_path
  end
  
  def login_bar
    render :partial => "shared/login_bar"
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree-enriquez-0.9.4 app/controllers/user_sessions_controller.rb
spree-0.9.4 app/controllers/user_sessions_controller.rb
spree-0.9.3 app/controllers/user_sessions_controller.rb
spree-0.9.2 app/controllers/user_sessions_controller.rb
spree-0.9.1 app/controllers/user_sessions_controller.rb
spree-0.9.0 app/controllers/user_sessions_controller.rb