Sha256: dae590c126a135dfedcea42c4ea8c9a8e7f29b76c283f7ffcc9f6870c6af4b11

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

class Spree::UserSessionsController < Devise::SessionsController
  helper 'spree/base'

  include Spree::Core::ControllerHelpers::Auth
  include Spree::Core::ControllerHelpers::Common
  include Spree::Core::ControllerHelpers::Order
  include Spree::Core::ControllerHelpers::Store

  def create
    authenticate_spree_user!

    if spree_user_signed_in?
      respond_to do |format|
        format.html {
          flash[:success] = Spree.t(:logged_in_succesfully)
          redirect_back_or_default(after_sign_in_path_for(spree_current_user))
        }
        format.js {
          render json: { user: spree_current_user,
                           ship_address: spree_current_user.ship_address,
                           bill_address: spree_current_user.bill_address }.to_json
        }
      end
    else
      respond_to do |format|
        format.html {
          flash.now[:error] = t('devise.failure.invalid')
          render :new
        }
        format.js {
          render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity
        }
      end
    end
  end

  protected

  def translation_scope
    'devise.user_sessions'
  end

  private

  def accurate_title
    Spree.t(:login)
  end

  def redirect_back_or_default(default)
    redirect_to(session["spree_user_return_to"] || default)
    session["spree_user_return_to"] = nil
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spree_auth_devise-3.4.2 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.4.1 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.4.0 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.3.3 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.3.1 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.3.0 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.3.0.rc1 lib/controllers/frontend/spree/user_sessions_controller.rb
spree_auth_devise-3.2.0 lib/controllers/frontend/spree/user_sessions_controller.rb