Sha256: 691268650b260fd7fc9a4b827204d11a719dff44ffcdacb4e1a2b68c6366bdf2

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

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

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

  helper 'spree/admin/navigation'
  layout :resolve_layout

  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 {
          user = resource.record
          render json: { ship_address: user.ship_address, bill_address: user.bill_address }.to_json
        }
      end
    else
      flash.now[:error] = t('devise.failure.invalid')
      render :new
    end
  end

  def authorization_failure; 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

  def resolve_layout
    case action_name
    when "new", "create"
      "spree/layouts/login"
    else
      "spree/layouts/admin"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_auth_devise-3.3.3 lib/controllers/backend/spree/admin/user_sessions_controller.rb
spree_auth_devise-3.3.1 lib/controllers/backend/spree/admin/user_sessions_controller.rb
spree_auth_devise-3.3.0 lib/controllers/backend/spree/admin/user_sessions_controller.rb
spree_auth_devise-3.3.0.rc1 lib/controllers/backend/spree/admin/user_sessions_controller.rb
spree_auth_devise-3.2.0 lib/controllers/backend/spree/admin/user_sessions_controller.rb