Class: Spree::UserConfirmationsController

Inherits:
Devise::ConfirmationsController
  • 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_confirmations_controller.rb

Instance Method Summary collapse

Instance Method Details

#create {|resource| ... } ⇒ Object

POST /resource/confirmation

Yields:

  • (resource)


24
25
26
27
28
29
30
31
32
33
# File 'lib/controllers/frontend/spree/user_confirmations_controller.rb', line 24

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

#show {|resource| ... } ⇒ Object

GET /resource/confirmation?confirmation_token=abcdef

Yields:

  • (resource)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/controllers/frontend/spree/user_confirmations_controller.rb', line 37

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