Sha256: d308910e9e5a67617b553b23a15d377a254701bb8f9a944b9b826fb1fbf325c3

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

class Spree::UserConfirmationsController < Devise::ConfirmationsController
  helper 'spree/base'

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

  before_action :set_current_order

  if Spree.version.to_f >= 4.2
    # POST /resource/confirmation
    def create
      self.resource = resource_class.send_confirmation_instructions(resource_params, current_store)
      yield resource if block_given?

      if successfully_sent?(resource)
        respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
      else
        respond_with(resource)
      end
    end
  end

  # GET /resource/confirmation?confirmation_token=abcdef
  def show
    self.resource = resource_class.confirm_by_token(params[:confirmation_token])
    yield resource if block_given?

    if resource.errors.empty?
      set_flash_message!(:notice, :confirmed)
      respond_with_navigational(resource) do
        redirect_to after_confirmation_path_for(resource_name, resource)
      end
    elsif resource.confirmed?
      set_flash_message(:error, :already_confirmed)
      respond_with_navigational(resource) do
        redirect_to after_confirmation_path_for(resource_name, resource)
      end
    else
      respond_with_navigational(resource.errors, status: :unprocessable_entity) do
        render :new
      end
    end
  end

  protected

  def after_confirmation_path_for(resource_name, resource)
    signed_in?(resource_name) ? signed_in_root_path(resource) : spree.login_path
  end

  def translation_scope
    'devise.confirmations'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_auth_devise-4.3.1 app/controllers/spree/user_confirmations_controller.rb