module Spree::CheckoutControllerDecorator
Public Class Methods
prepended(base)
click to toggle source
# File lib/controllers/frontend/spree/checkout_controller_decorator.rb, line 3 def self.prepended(base) base.before_action :check_authorization base.before_action :check_registration, except: [:registration, :update_registration] end
Public Instance Methods
registration()
click to toggle source
# File lib/controllers/frontend/spree/checkout_controller_decorator.rb, line 8 def registration @user = Spree.user_class.new @title = Spree.t(:registration) end
update_registration()
click to toggle source
# File lib/controllers/frontend/spree/checkout_controller_decorator.rb, line 13 def update_registration if order_params[:email] =~ Devise.email_regexp && current_order.update_attribute(:email, order_params[:email]) redirect_to spree.checkout_state_path(:address) else flash[:error] = t(:email_is_invalid, scope: [:errors, :messages]) @user = Spree.user_class.new render 'registration' end end
Private Instance Methods
check_registration()
click to toggle source
Introduces a registration step whenever the registration_step
preference is true.
# File lib/controllers/frontend/spree/checkout_controller_decorator.rb, line 38 def check_registration return unless Spree::Auth::Config[:registration_step] return if spree_current_user || current_order.email store_location redirect_to spree.checkout_registration_path end
order_params()
click to toggle source
# File lib/controllers/frontend/spree/checkout_controller_decorator.rb, line 25 def order_params params[:order].present? ? params.require(:order).permit(:email) : {} end
skip_state_validation?()
click to toggle source
# File lib/controllers/frontend/spree/checkout_controller_decorator.rb, line 29 def skip_state_validation? %w(registration update_registration).include?(params[:action]) end