Class: Spree::UserSessionsController

Inherits:
Devise::SessionsController
  • Object
show all
Includes:
Core::ControllerHelpers::Auth, Core::ControllerHelpers::Common, Core::ControllerHelpers::Currency, Core::ControllerHelpers::Locale, Core::ControllerHelpers::Order, Core::ControllerHelpers::Store, LocaleUrls, SpreeI18n::ControllerLocaleHelper
Defined in:
lib/controllers/frontend/spree/user_sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/controllers/frontend/spree/user_sessions_controller.rb', line 22

def create
  authenticate_spree_user!

  if spree_user_signed_in?
    respond_to do |format|
      format.html {
        flash[:success] = Spree.t(:logged_in_successfully)
        redirect_back_or_default((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, status: :unprocessable_entity
      }
      format.js {
        render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity
      }
    end
  end
end